freenode/#lisp - IRC Chatlog
Search
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.
22:10:28
Josh_2
pjb has already been through this with me when I have talked about making this kinda metaclass before
22:55:55
sveit
hello. does the maintainer/anyone familiar with the internals of the series package hang out here?
22:55:57
sveit
i have found several bugs that i would appreciate advice on how to begin attacking (as well i would love to discuss the package in general). i have also "fixed" a bug that seemed too trivial/actively introduced to have as simple a fix (deleting a line) as it did, and would like to know if i made an oversight before submitting.
23:03:12
sveit
well thanks for the update :) i am surprised, imo it is a great idea, and a great demonstration of something that could really only be done in lisp
23:03:39
sveit
if people have free time, writing non-trivial code and looking at the series macroexpansions/optimizations is pretty remarkable. except for the bugs :)
23:05:08
sveit
anyway, if anyone has looked at it before or knows of similar code and has general wisdom i'd like to hear it, since series is written in a somewhat haphazard way.
23:06:48
sveit
actually if it is abandoned i assume people have alternative libraries that they use to accomplish similar things?
23:55:44
fwoaroof[m]
I've also implemented clojure-style transducers for a kind of explicit stream-fusion approach
23:57:27
fwoaroof[m]
I like this better than series-style stream fusion, because it's not as dependent on "magic" compile-time transformations
23:58:59
sveit
the problem with loop is "reusability" and "composition"; it is kind of tricky/impossible to have some independent looping constructs that can be combined in a generator style. the idea of series is (imo) to provide this while having loop-style performance when the computation is actually built up
0:00:01
sveit
even the trivial idea of "loop from float F1 to float F2 with N samples" is irrating to write over and over again
0:01:30
fwoaroof[m]
You probably could fork series and put it on quicklisp with a new name, if you want to maintain it :)
0:02:40
fwoaroof[m]
Some LOOP implementations can be extended, but that's not specified in the standard
0:03:10
sveit
i know about iterate, but i think series is much more elegant and powerful (here the elegance is in the using, not the implementation :)). i probably will try to fork/maintain when life calms down a bit :) for now i just have my list of bugs.
0:05:07
fwoaroof[m]
SERIES relies on the ability to inspect declarations and do compile-time transforms, which I believe relies on either environment introspection or a code-walker
0:06:10
fwoaroof[m]
Transducers are pretty straight-forward to implement "in userspace" and are basically equivalent, from a composition/reusability perspective
0:06:33
fwoaroof[m]
https://github.com/fiddlerwoaroof/lisp-sandbox/blob/master/transduce.lisp#L152-L158
0:07:08
fwoaroof[m]
Basically, the idea is you have MAP/FILTER/REDUCE return functions that take a continuation
0:07:29
fwoaroof[m]
And you have another function that takes such functions and injects a function that builds up a result
0:08:29
sveit
fwoaroof[m]: i see. is SBCL magical enough that this performs comparably to series/loop?
0:09:13
fwoaroof[m]
In most cases, though, I expect it to be significantly faster than map/remove-if-not/etc., once your collections get significantly large
0:10:26
fwoaroof[m]
I think, in most cases, the performance difference with series/loop either doesn't matter because the collections are small, or doesn't matter because your code is more modular
0:13:04
sveit
yeah, the point of comparison is really series/loop, since the former works very hard to not build up intermediate collections, and in the latter you ensure this manually. i wonder more for the case of something like a nested loops over floats where you skip certain elements based on a predicate, otherwise call some function with side-effects on the float. the series case is as fast as a handwritten loop.
0:13:53
fwoaroof[m]
I suspect compiler macros for ALEXANDRIA:COMPOSE and for these functions can solve most of the performance issues
0:14:00
sveit
with enough inlining i would believe sbcl makes your continuation approach comparable, but i would have to check
0:14:56
fwoaroof[m]
I just think that the benefit of being able to use MAP/FILTER/REDUCE without intermediate collections and without compiler magic usually outweighs the performance difference
0:15:22
fwoaroof[m]
But, I'm generally on the expressiveness side of the performance vs. expressiveness debate :)
0:16:13
fwoaroof[m]
Which is dominated by the overhead of calling a closure in your implementation of choice
0:16:43
sveit
i usually fall on the performance side, but everyone i know that does software in a serious way is the opposite of me and like you, so i am slowly learning :)
0:17:39
fwoaroof[m]
I think from a cost standpoint, it's usually less expensive for a company to buy extra hardware rather than making their programmers less efficient
0:19:03
sveit
fwoaroof[m]: but despite it being a micro-optimization, i really do think in tight (numerical) loops it's worth getting rid of that closure. i basically think of series in this "transducer" way, but with lots of optimizations to remove function calls and fuse loops. and a couple of bugs :)
0:21:11
sveit
the other neat thing is if you are processing several series in parallel or use them more than once, it will tend to figure out how to loop over the series just once. for example, reasonable code to compute the mean and length of a series, which look like separate loops over a series, are compiled to a single loop.
0:22:21
sveit
i think it might be tricky to do this outside of the series approach, but maybe it's not even worth it to fuse the loops like this. apparently some hardware and compilers will de-fuse loops in fact :)
0:22:59
fwoaroof[m]
I use transducers in Clojure all the time for work, and I think they're one of the best parts of the language.
0:23:28
fwoaroof[m]
I should look into how series is implemented, though: it feels like a bad sort of magic, which has always put me off using it
0:31:19
sveit
fwoaroof[m]: the code is not too pleasant imo, but if you start looking at it/using it feel free to ping me again, like i said i have at least one trivial bugfix and can tell you what to avoid to keep series happy