freenode/#lisp - IRC Chatlog
Search
10:35:40
minion
Josh_2, memo from mrcom: EFFECTIVE-SLOT-DEFINITION is a virtual class and should not be directly instantiated. See https://stackoverflow.com/questions/21986977/additional-properties-to-slot-definition
10:35:40
minion
Josh_2, memo from mrcom: Other notes: looks like you're trying to set up a circular dependency with VALIDATE-SUPERCLASS. "`',slot-names-lock-alist" isn't... what you want. The INITFUNCTION is the proper way to do it, completely overriding :INITFORM and :INITARG.
10:35:40
minion
Josh_2, memo from mrcom: And I suspect your end goal is automatically thread-safe slots. This is a common thought, but kind of a dead-end. The primary issue with thread-safety isn't reading or updating a single slot. It's the higher-level cross-slot operations (e.g. changing STREET-ADDRESS and CITY), cross-object (updating object's address and the ADDRESS-HASH-TABLE that points to it), and global (making sure there's only one obje
10:35:40
minion
Josh_2, memo from mrcom: You'll probably find you need a single mutex per object, and one or more global mutexes. Most importantly, you'll need to define atomic functions/generic functions, and these will be completely aware of the mutexes.
10:35:40
minion
Josh_2, memo from mrcom: In other words, you aren't going to need a broad superclass which invisibly adds lock slots.
10:40:02
Josh_2
mrcom: I can get slot-value to grab a mutex using an :around on slot-value-using-class. I guess this could just be one aspect of a library I could create to aid with making parallel systems, because handling locks is such a pita
10:42:01
Josh_2
I'm also not trying to add additional properties to my slot definition, i simply want to append an extra slot
10:53:12
phoe
2) you can use with-slots based on the fact that, even though it's undefined by the standard, the last time I checked *ALL* implementations defined SLOT-VALUE on structures in a meaningful way, the same that you could expect from standard objects.
10:53:39
phoe
and suggesting option 2) is going to get me a real good scolding from beach in a few moments
10:59:28
jackdaniel
I think that it is a pretty bold omission to not even mention the structure-class metaclass in mop
11:39:00
Josh_2
I added a method for my metaclass and it worked just as expected, when I call slot-value slot-value-using-class was called (in sbcl)
11:39:50
jackdaniel
"Although no implementation is required to do so, implementors are strongly encouraged to implement the function slot-value using the function slot-value-using-class described in the Metaobject Protocol. "
12:49:51
tourjin
clang-10: error: linker commnad failed with exit code 1 ( use -v to see invocation)
12:51:48
mrcom
Josh_2: Yep, you're approaching the problem from bottom-up. You'll learn a lot about MOP in the process. Just warning you that you'll discover locking individual slots doesn't buy you much.
12:51:59
jackdaniel
that means that clang failed to link some objects after compiling them, this error doesn't allow to infere more from that
12:56:50
phoe
Josh_2: (defun frobnicate (object x y) (setf (slot-value object 'foo) x (slot-value object 'bar) y))
12:57:27
phoe
even if both slots are synchronized you still can get race conditions from two simultaneous calls to FROBNICATE
12:59:14
tourjin
document says sbcl can be compiled with ecl. so I tryed all day but only failed with several warnings and clang-10 error
13:04:51
mrcom
Josh_2: On 64-bit X86, 64-bit-aligned updates are atomic. Implementations are going to align CONS cells on words.
13:06:37
mrcom
Josh_2: Setting a slot value boils down to updating the CAR of the slot, which will be an atomic 64-operation. One instant the slot will point to the old value, and then the next to the new.
13:11:24
jackdaniel
afair the problem with getting cl-repl there were problems of f-droid maintainers to build the thing, but that was 2y ago or so
13:15:46
eta
i.e. something similar to the (DECLARE (FTYPE ... )) declaration, but for runtime lambda values
13:25:16
eta
ldb, I want to validate that a callback passed into my function takes the right arguments
13:30:09
luqqy
just reflecting here, but one thing that sort of bugs me about common lisp is that functions aren't truly first class citizens
13:30:35
ldb
eta: you may require the client function to by a structure with the function and an validating object
13:31:22
jackdaniel
luqqy: that's a feature. if you want first-class objects, you may subclass a funcallabe-standard-class and setf it to (fdefinition 'symbol)
13:33:04
phoe
if you want FTYPE declarations that you can try to then take apart to validate arglists against, then you can use trivial-cltl2:function-information
13:37:19
luqqy
ldb, beach: lisp 2 for once, the problem eta voiced for two. ok, maybe i am being too brisk about this. there also was a pun in my complaint btw
13:39:09
phoe
eta: figure out how FUNCTION-INFORMATION behaves when there's multiple FTYPE declarations, then, and write something that validates your arguments against each FTYPE declaration it finds there
13:40:12
beach
luqqy: You are pretty new here, it seems. Maybe you need to ask question rather than affirming false statements.
13:40:14
eta
phoe, I mean, to be honest, it's probably more idiomatic to make the thing into a promise returning some CLOS class instead of doing it the callback-ey way
13:40:41
phoe
eta: that's a more troublesome question because it requires some context about what you're doing
13:41:04
eta
phoe, I'm writing a whatsapp library -- you make some request, like "upload a file", and get back some information asynchronously about where to put the file
13:41:04
phoe
but if you need to dive into low-level declaration stuff like this, then there's some mechanisms for that
13:41:28
eta
the issue is "how do I return these 4 pieces of information asynchronously in the most idiomatic way?"
13:42:06
eta
phoe, yeah, I'm already using that elsewhere in the codebase, so I'll probably do that :)
13:42:28
phoe
the erlangesque way of doing stuff is really nice when it comes to modeling asynchronous processes
13:42:34
eta
I've been burned by callbacks a few times with this project, so yeah, I am gonna make it all use message-passing
13:42:58
eta
plus then I can define the messages as CLOS classes and use defgeneric/defmethod dispatch :)
14:42:43
Josh_2
also I understand that you may consider this a fruitless exercise, however I'm doing it as an attempt to learn to use the MOP
15:24:46
treflip
Also, Emacs + Slime + Orgmode. It's a great environment for mixed interactive programming.
15:56:35
mrcom
Josh_2: "Because I want to" is perfectly acceptable. "It will teach me something" is a commendable reason.
15:58:26
mrcom
Josh_2: It will also teach you a lot about parallelism. Take what I said as foreshadowing; it *may* be enlightening in the future.
15:59:06
Inline
but anyway, when i start it i get a connection, but soon after the connection dies the server vanishes, and the stale connection gets tried to be replace forever....
16:03:49
Inline
ok the install-image succeeds but cl-jupyter:install just fails, because then there's no reference to the quicklisp package obviously
16:14:47
mrcom
Josh_2: Points that might help: *1* Don't even think about _changing_ the standard classes. You're extending them into new child meta classes, which will be explicitly instantiated.
16:17:01
mrcom
Josh_2: *2* Think of the MOP as "macros for classes". A good way of developing macros is to first manually write some of the DEFUNs you want to wind up with. Same thing for classes.
16:25:40
mrcom
Josh_2: So, manually create some classes with the slot mutexes, and redefine the accessors with DEFMETHODs.
16:47:55
mrcom
Good. Start with adding the extra slots you'll need. Keep your manual redefinitions of the accessors, for now.
16:50:00
jackdaniel
I'm sure that you can do (dotimes (f files) (bt:make-thread (lambda () (compile-file f))))
16:51:06
mrcom
Josh_2: OK, you're trying to extend standard-effective-slot-definition now, not instantiate effective-slot-definition?
16:53:10
Josh_2
also in AMOP they use :initform how I have, I don't understand why you told me not to
16:54:52
jackdaniel
I don't know how sbcl compiles inside its compile-file function, and calling compile-file is completely up to you
16:56:06
mrcom
Josh_2: The standard says not to: https://clos-mop.hexstreamsoft.com/classes/#standard-slot-definition
16:56:31
mrcom
"This class is an abstract class and is not intended to be instantiated. The results are undefined if an attempt is made to make an instance of this class with make-instance."
16:57:06
Josh_2
I'm making an instance of direct-slot.. in that code and I have tried effective-slot as well
16:57:38
Bike
it looks like you're making a direct-slot-definition, not a standard-direct-slot-definition?
16:57:42
mrcom
Sorry, wrong abstract class. But same thing for direct-slot-definition. https://clos-mop.hexstreamsoft.com/classes/#direct-slot-definition
17:05:58
mrcom
Ohh... You shouldn't create LOCKED-OBJECT class before you've finished setting up METACLASS.
17:07:41
mrcom
It might be OK, but the main point of a metaclass is automating the creation of subclasses, not automating instances of the subclass.
17:18:24
mrcom
Also note http://www.sbcl.org/manual/index.html#AMOP-Compatibility-of-Metaobject-Protocol
17:32:29
mrcom
Ah. You're trying to put the slot locks in the _metaclass_. They can go directly in the class, or in the _superclass_.
17:32:59
mrcom
_Metaclasses_ are the macros; they tell how to create the _classes_, not the instances.
17:34:58
Josh_2
mrcom: Hmm I thought I was trying to append the alist (of locks) onto any class whose metaclass is 'metalock'
17:35:10
jackdaniel
you can describe everything in terms of metaphysical input-output, but I think that this metaphore is not very useful
17:37:00
mrcom
And that's the way you should think of a metaclass. It transforms a class definition.
17:39:31
mrcom
jackdaniel: The point I'm trying to correct is that anything specific to an instance resides in a metaclass. It doesn't. You can put the equivalent of _class variables_ in a metaclass, but that's not where he's at.
17:41:14
mrcom
To possibly beat a dead horse: Metaclasses are only used when creating a _class_. Once the classes have been created you could, pretty much, delete the metaclasses.
17:41:44
jackdaniel
custom metaclass may be i.e. used to hold all this class instances in a weak hash table, and that's a very valid use of the metaclass protocol
17:43:42
mrcom
jackdaniel: Yep, but that's an even more advanced topic. Josh has been trying to wrap his head around plain old instance slots. (Which, BTW, is a very common sticking point when dealing with metaclasses.)
17:44:23
jackdaniel
I think that comparing metaclasses to macros, and saying that metaclass "transforms" the class is harmful for understanding what they are because it builds a wrong intuition
17:44:43
jackdaniel
I think I don't have much more to say on this topic, so I'll put my keyboard to rest
17:46:36
jackdaniel
as well as adding custom initargs to slots (i.e :required t, or :encrypted t) etc
17:47:38
jackdaniel
fact that mop is so versatile is unfortunate at times, especially for compilation time optimizations
17:48:09
Josh_2
I'm basically just copying half the example from the book as I only want to add an extra slot
17:50:31
mrcom
Nor is the second VALIDATE-SUPERCLASS defmethod (STANDARD-CLASS is not s subclass of METALOCK)
17:50:56
VincentVega
Guys, how do you deal with this problem? When I do eval-defun on (loop) in emacs, I seem to be able to do nothing to interrupt it's execution. If I executed (loop) in REPL, I can do sly-interrupt, but that trick doesn't work with sly-eval-defun. Help please?
17:52:41
mrcom
Josh_2: The SLOT-VALUE-USING-CLASS doesn't do anything, either. It's locking around the metaclass's slots, not the instance's.
17:54:20
mrcom
Josh_2: Don't... think so. You were probably seeing the lock messages, but that was while the class was being created.
17:55:18
VincentVega
nirved: that's the thing, sly-interrupt doesn't work in this situation (btw I am using sly but it's based on slime)
17:56:07
mrcom
Don't think you need the EFFECTIVE-SLOT-DEFINITION-CLASS or DIRECT-SLOT-DEFINITION-CLASS method redefintions either, since they should already return the standard classes.
17:56:34
mrcom
Josh_2: Yeah, I'm just running down the code eliminating stuff that _isn't_ the problem.
17:57:10
_death
VincentVega: when you evaluate it in a lisp buffer, a thread is created to evaluate the form.. you need to interrupt the right thread
17:57:19
VincentVega
nirved: oh, crap, I was trying to interrupt in the repl window, while I had to call it from the buffer window, so yes it works!
18:05:35
mrcom
And I think it was a problem because EFFECTIVE-SLOT-DEFINITION class returns STANDARD-effective-slot-definition, not effective-slot-definition (again, a virtual class which isn't supposed to be instantiated.)
18:13:23
mrcom
Yes, you are correct, using closer-mop is portable. It resolves to the SB-MOP calls on SBCL.
19:23:08
Josh_2
Perhaps I could develop my toy into something actually useful for developing parallel applications
19:27:31
mrcom
Josh_2: Here's a challenge for you: Given an instance X of FOO, a METALOCK class, and (SETF (FOO-SLOT1 X) 42 (FOO-SLOT2 X) 99)
19:29:20
mrcom
Josh_2: In another thread, make (CONS (FOO-SLOT1 X) (FOO-SLOT2 X)) always return either (42 . 99) or the pre-SETF values.
19:34:08
Alfr_
mrcom, and when he's done with that you could just add a slot for a similarly interesting problem, repeat. I think, the underlying problem is that individual atomic operations just don't compose well.
19:36:44
mrcom
I was just being facetious. It won't really dawn on him until he's worked it out himself.