libera/commonlisp - IRC Chatlog
Search
17:56:40
EdLangley[m]
If the generic function is created by generic-flet is created once, at load time
17:57:10
EdLangley[m]
Then it's possible to implement the (:method ...) part in a way that that EQL specializer adds a new method every time the function runs
17:58:12
EdLangley[m]
So, first of all, you'll have an indefinitely growing collection of methods attached to the l-t-v generic function
17:58:44
EdLangley[m]
And the EQL specializer of each method will keep an instance of BIG-OBJECT alive as well
18:02:39
lisp123
For some reason, every time I restart my Lisp image, I need to reset the ASDF configuration to load a recently defined pacakge
18:04:41
Bike
i've never quite understood what it would be good for, so i'd be interested in seeing usage
18:05:51
EdLangley[m]
For me, at least, it's more a nicer syntax for a typecase inside a lambda, when you're mapping over a bunch of objects of different types
18:06:48
phoe
so, like, try to compile the method functions once, and then just close over the arguments that the GF needs to close over
18:07:19
EdLangley[m]
the issue I ran into was figuring out how to capture the lexical environment correctly
18:08:28
EdLangley[m]
but, I was trying to do it through the MOP rather than using DEFGENERIC and friends
18:09:00
phoe
the main hurdle I see is COMPILE being a butt in presence of lexical bindings, if we want to be strictly compliant
18:10:40
phoe
I mean, if DEFGENERIC can properly capture the lexical environment, then the MOP must be able to as well
18:10:58
EdLangley[m]
Yeah, I couldn't figure out how to make the stuff inside COMPILE able to access the lexical enviroment
18:11:43
phoe
special opeartor FUNCTION itself must access the lexical environment; if anything, you just COMPILE whatever is the result of it
18:12:17
phoe
and you need to compile the function object that pops out when you evaluate a call to FUNCTION
18:12:40
mfiano
Can I change the displaced-index-offset of an existing displaced array object to be able to updated the displaced-to array at different locations without constructing multiple displaced arrays?
18:12:53
phoe
this, and there's the interaction with MAKE-METHOD-LAMBDA that needs to be taken into account
18:12:59
EdLangley[m]
I remember I spent a long time looking at the macroexpansion and definition of DEFMETHOD trying to figure this out
18:14:02
phoe
EdLangley[m]: I think the macroexpander needs to call MAKE-METHOD-LAMBDA and splice the result of calling it into the macroexpansion
18:15:26
EdLangley[m]
(adjust-array array (array-dimensions array) :displaced-to whatev :displaced-index-offest 4)
18:15:30
Bike
the rules for this are a large part of the definition, even, since it's kind of complicated
18:15:50
mfiano
Does asjust-array specify if a new array object is created or if the index pointer is moved?
18:16:01
Bike
also, yes, for generic-flet you'd want to go through the make-mmethod-lambda rigamarole and avoid actually calling COMPILE.
18:16:36
Bike
mfiano: a new object is only created if the array isn't "actually adjustable". you can assure an array is actually adjustable by specifying :adjustable t in make-array.
18:17:09
mfiano
Ok, and I can make the displaced array adjustable without affecting the displaced-to simple-array?
21:34:36
phoe
and if any method closes over an argument, then we're screwed, because we need to return different objects for different closures - so we cannot preallocate a single LOAD-TIME-VALUE GF, we need to create them from scratch
21:35:22
phoe
...but the good news is, we can expand GENERIC-FLET into a FLET of method functions and have these precompiled - we only need to create the method and GF metaobjects, add methods to the GF, and FBIND the GF - and we're good to go
21:36:51
phoe
and, if we can detect that the local function is DX (either via a user declaration or by code-walking, if we do not notice any FUNCTION calls referring to that free function binding) then we can use the optimized approach with a single LOAD-TIME-VALUE GF and, in case of closures via EQL specializers, adding or removing methods on entry/exit of dynamic scope
21:51:29
Bike
so generic-flet only ever makes a new function, rather than adding to an existing one?
21:52:31
phoe
even the CLtL2 GENERIC-FLET always creates new local GFs, it doesn't augment any preexisting ones
21:52:40
EdLangley[m]
Yeah, I think dynamically changing the methods of a pre-existing generic function is asking for sadness
21:53:28
phoe
because then we can preallocate a single GF along with N methods and just switch their guts around on demand
21:55:20
phoe
Bike: AFAIK it's syntax sugar + optimization chances over creating anonymous GF objects and using these
21:57:11
EdLangley[m]
On reflection, anonymous GFs aren't very useful because the reason to use a GF is to let 3rd party code interoperate with your own code
21:57:41
EdLangley[m]
But, if the GF is defined hidden inside a function, there's no way to do this.
22:03:50
phoe
so I think it should be possible to write (and even optimize) GENERIC-FLET and GENERIC-LABELS using portable CL, MOP, and a code walker to detect FUNCTION calls; GENERIC-LAMBDA is also obviously possible
22:04:47
phoe
the question is, do we have any practical reasons other than going full Cave Johnson on this
22:04:54
phoe
and by Cave Johnson, I mean, quote, "Science isn't about WHY. It's about WHY NOT. Why is so much of our science dangerous? Why not marry safe science if you love it so much."
22:06:15
phoe
I mean, you could in theory grab a local GF object via #' and then forcibly ADD-METHOD some stuff into it
22:08:25
EdLangley[m]
A lot of the generic-flet stuff could probably just be written as a fancy macro for a typecase
22:08:39
phoe
yes, and then maybe some people would enjoy the local :METHOD syntax and qualifiers for method combinations
22:13:11
phoe
you should be able to statically analyze this, especially if no qualifiers are used, and just turn this into a non-generic function with a big ole TYPECASE inside
22:15:03
phoe
and optionally fall back to standard MOP wizardry in case any unrecognized options are present, e.g. a custom metaclass
22:46:26
Bike
fbind a function of one argument for each "method". have that one parameter be #'call-next-method. the typecase calls a method appropriately
22:50:59
Bike
next-method-p is a little more involved but not much. passing no-next-method a method would be trickier
23:37:40
dbotton
Is there a convention used in code for a variable named "this" or "self" by Common Lispers?
23:38:31
Bike
i don't think so. generic functions are not strongly tied to any argument in particular.
23:45:00
phoe
I think that generating code for the user is going to be harmful if it teaches the user that there is some sort of "self" in methods
23:45:05
dbotton
however since the name of BAR can change with a configuration change it means every thing has to generated again
23:45:21
EdLangley[m]
Some things like PRINT-OBJECT use OBJECT or similar for the parameter the user is expected to specialize
23:46:23
phoe
"methods should therefore not depend on the identity of this stream." is the only thing that's mentioned
23:46:50
EdLangley[m]
but, if you can't depend on the identity of the stream, you can't rely on it being the class you expect it to be
23:48:00
phoe
dbotton: the main issue I see is, what meaning do you want to convey - argument names can be completely dumb like ARGUMENT-1 ARGUMENT-2 ARGUMENT-3 and so on, but they are meaningless
23:48:17
phoe
if you are telling the user to configure something, use the argument names to tell them what they are configuring
23:48:28
mfiano
Just name it what the most specific thing that it can be, not something generic like THIS or SELF that has a single-dispatch connatation
23:49:05
mfiano
Hell I'd use single letters over that. That would send the wrong message to a newcomer.
0:12:49
dbotton
i'll think it over, wonder if another word works better for object of event, maybe target
2:38:09
dbotton
Is there a way in common lisp to turn off a style warning for unused variables for a certain region beyond using (declare (ignore target))?
2:46:47
Bike
Not really. Maybe you can swing something with sbcl's muffle-conditions extension though
2:47:42
etimmons
Or declare them ignorable (if the problem is that it's hard for you to tell if they are actually used)
3:44:38
kathe
would you be in a position to comment on which is a good common lisp programming environment under macos?
3:45:33
kathe
i "was" going to migrate to windows and hence use lispworks, but macos is looking very impressive.
3:52:47
semz
kathe: Clozure CL is probably a good choice, it focuses on Macs quite a bit and I think it even has its own IDE on there (although I've never used it so I can't say anything about its quality)
3:59:38
kathe
hmnn, hemlock is very interesting, but doesn't have the wide array of modes available with 'gnu' emacs.
4:02:38
kathe
i don't have any background in common lisp nor emacs, and i'm a bit confused about how to learn both in parallel without messing up my thought process.
4:03:45
kathe
so should i first work through the emacs tutorial and manual, get well acclimatised with emacs and then start-off with common lisp?
4:05:52
kathe
i had been quite gung-ho about forth, but after my interaction with some people from it's community regarding introducing a "condition system" and an object system via a metaobject protocol were shot down, i'm going to stick with common lisp.
4:07:35
kathe
thanks EdLangley, i think i'm going to stick with ubuntu. not only does it offer better facilities for development systems but a ubuntu-based setup also costs a lot lesser than a mac.
4:09:47
White_Flame
those who don't use emacs are forging their own path, and yeah hopefully other paths get as fully supported
4:10:32
ns12
kathe: What text editor are you currently using? Perhaps your current text editor has some support for Common Lisp. This will free up more time for learning Common Lisp.
4:11:16
kathe
i cut my teeth on 'sco' openserver so i tend to lean toward vi (not vim), but i'm eager to learn emacs because of the tight integration with common lisp development routines.
4:11:17
White_Flame
after sbcl & emacs, you want to install, in order: quicklisp, quicklisp-slime-helper
4:11:42
White_Flame
you shouldn't really need to adjust any config files after following their steps
4:12:38
EdLangley[m]
https://portacle.github.io is also a good way to get a nice package of "all of the above"
4:12:52
ns12
I personally use the SBCL REPL directly (with rlwrap for readline keybindings). That's another way to defer learning Emacs.
4:13:51
White_Flame
lots of cheat sheets, if you're learning: http://pchristensen.com/wp-content/uploads/2008/02/slimecommands.pdf
4:13:58
minion
kathe: look at PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
4:14:57
ns12
Here's a list: https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md#lisp
4:18:58
ns12
In the free books list, "Practical Common Lisp" and/or "Common Lisp: A Gentle Introduction to Symbolic Computation" are typically recommended to beginners.
4:19:31
kathe
I checked out slimv and vlime based setup, but i think i'll go with emacs because i can do almost everything else from within emacs (irc, email, notes, todo, etc.).
4:20:33
kathe
ns12: i've heard that the digital version of touretzky's book doesn't have corrections present in the paperback one.
4:23:12
kathe
2 things that most impress me about common lisp are the "condition system" and the "metaobject protocol" based object-system.
4:26:15
kathe
i don't remember finding the "condition system" in autolisp, nor did any of the seniors talk about it back then.
4:28:33
Bike
"The *error* function takes a single string argument, which is supplied by AutoCAD when an error is encountered during program evaluation. This string describes the error which has caused the *error* function to evaluate." doesn't sound like it has the condition system
4:30:22
kathe
i went through the sample session in phoe's "Appendix E". it's mind blowing. waiting to complete learning common lisp and buy phoe's book on the "condition system".
4:36:43
mfiano
I'd need conformal displacement for anything more than a flat row-major view of the backing storage, correct?
4:38:52
mfiano
Currently I only need a view of a pixel in a '(width height channel-count) #3a, but I was also thinking of things like a NxM kernel view for convolutions.
4:40:16
mfiano
Guess I could just derive the shape/extents from a single pixel and mutate the original directly.
5:16:04
qhong
recalling the discussion about software longevity a few days ago, what you guys think about a Nix/Guix replicate that runs in a single Lisp image a la asdf?
5:30:07
kagevf
I use guix to install nyxt since that's the only way I could figure out how to get all the right versions of nyxt, sbcl, and emacs ... necessary to connect to nyxt's swank server from slime
5:32:31
kagevf
qhong: what would the nix/guix inside CL do? find, and build CL systems? and allow easy switching between different versions? and also act as a package manager? so it would replace asdf and QL, plus add the versioning?