libera/#commonlisp - IRC Chatlog
Search
13:33:43
pjb
It' strange that compiler-macro-function takes an environment parameter, but it can only be NIL for (setf compiler-macro-function).
13:38:07
Bike
compiler-macro-function needs it because compiler macros can be shadowed by local functions
13:38:22
Bike
but also, typep and subtypep and find-class take environment parameters, and there's no concept of local types
13:39:44
beach
Can those just be different global environments, like the ones mentioned for file compilation?
13:43:47
beach
So it looks like DEFTYPE can be defined in the compilation environment, so the environment to TYPEP and SUBTYPEP could be a compilation environment.
13:45:15
jackdaniel
could it be that find-class when used with compilation environment yields a forward referenced class instance standing for a class that is defined in this compilation unit?
13:52:49
pjb
Bike: oh I see, so with a lexical environment compiler-macro-function could return NIL because its (global) function is shadowed.
13:53:28
pjb
The magic of a specification: if you use it to implement something, it works even if you don't understand it! :-)
14:01:36
beach
So does that mean that DEFCLASS always defines the class in the evaluation environment?
14:01:37
jackdaniel
fwiw mcclim does a funny thing: it records presentations at compile time and tries to attach them to functions at run time (because as you have noted it may be a different class by then :)
14:03:30
Bike
what clasp does now is note any accessors in a similar way to what it does for defuns, and then sets an internal "class-info" in the environment, which covers the stuff where later sub/typep calls need to recognize it as a type, etc
14:05:14
beach
An environment parameter of a macro is always going to be the compilation environment, and the compilation environment inherits from the evaluation environment.
14:05:35
beach
So if the class is defined in the evaluation environment, that makes the phrase in the Common Lisp HyperSpec make sense.
14:06:14
beach
But my hypothesis is that the wording of the Common Lisp HyperSpec means that it always is.
14:07:32
Bike
evaluating defclass forms at compile time at all can cause issues. people do things like put a defclass form and a related validate-superclass method definition in the same file.
14:08:18
beach
I am not saying it is a good idea. I am just speculating about the meaning of the wording in the Common Lisp HyperSpec.
14:09:54
beach
It could be a forward-referenced-class as jackdaniel suggests. Nothing is said about the utility of the class at compile time. Just that FIND-CLASS must return it.
14:09:55
Bike
https://github.com/clasp-developers/clasp/issues/926 e.g. here's an issue we hit with clim
14:09:56
jackdaniel
wouldn't evaluating (%compiler-defclass-using-internals-but-preserving-identity …) in the compilation environment suffice?
14:14:51
jackdaniel
beach: that there is no need to evaluate defclass at all, it is enough for the compiler to take a note and return something sensible from find-class
14:15:33
jackdaniel
(i.e if find-class is not called, then not define a class at all; and if it is called with the compiler environment make an instance of a forward-referenced class)
14:16:50
Bike
i think the main thing is i don't understand what you're supposed to be able to do with a find-class result, if anything
14:17:05
Bike
can you even do subtypep and stuff with it? couldn't the set of superclasses be affected by mop methods?
14:40:36
jackdaniel
i.e (if (find-class 'foo nil cmp-env) `(fast-something ,obj) `(slow-something (make-wrapper ,obj)))
14:42:10
beach
And in that case, just associating the name with a new forward-referenced-class in the evaluation environment will work.