freenode/#sicl - IRC Chatlog
Search
11:12:23
beach
OK, I'm confused. If the file compiler seeing a DEFCLASS has to create the class in the compilation environment, (so that FIND-CLASS will return it as the Common Lisp HyperSpec requires), then it appears to me that either
11:12:27
beach
1. the class created is not EQ to the one that will be created when the the compiled file is loaded,
11:12:33
beach
2. the file compiler has to create it in the startup environment instead of the compilation environment, or
11:12:35
beach
3. The startup environment or the compilation environment must be the same. I am not satisfied with any of these solutions.
11:41:05
Shinmera
1. seems to be the cleanest to me, and is definitely cleaner than option 4. don't make the class available in the compilation environment at all, which is what SBCL seems to do, if I recall correctly.
11:41:43
beach
Oh, 4 would be contrary to the requirement of the Common Lisp HyperSpec as I understand it.
11:43:21
jackdaniel
how about creating class prototype in compilation environment and promote it when it is loaded (if a prototype exists)? then eq will be preserved
11:48:27
beach
OK, I have a file to-delete.lisp containing (defclass bla () ()) (macrolet ((m (&environment env) (find-class 'bla env))) (m))
11:49:17
Shinmera
Sure, though it won't let me confirm whether, if find-class returns, it will be eq in the load env, so it needs a bit more
11:49:39
beach
Compiling it with SBCL signals an ERROR: (during macroexpansion of (M)) There is no class named COMMON-LISP-USER::BLA.
11:52:14
beach
Maybe (defparameter *c* '()) before compiling (so in the startup environment) and instead of (find-class 'bla env) I do (push (find-class 'bla env) *c*)?
11:54:13
beach
You need to save the return value of find-class at compilation time in the startup environment.
11:57:48
beach
Does everybody agree that the Common Lisp HyperSpec says that a class much be returned in my example?
12:17:58
Shinmera
beach: here's the results from the implementations I can run: https://plaster.tymoon.eu/view/1175#1175
14:42:43
beach
Yes, because they don't distinguish between the compilation environment and the startup environment.
14:43:59
Bike
i think in ccl a class is made at compile-time, and then change-class'd and altered into the load time class, so they are eq
14:44:48
beach
Bike: Maybe so, but it would still have to be created in the startup environment at compile time then.
14:45:11
Bike
what? really? i remember specifically testing this once. they had their own metaclass. weird...
14:46:32
Shinmera
Bike: https://plaster.tymoon.eu/view/1176#1177 this is my test case (load "b.lisp")
14:49:14
Bike
classes don't have any similarity rules, so if we're talking about loading a fasl in another image there's no way they could be similar
14:49:32
Shinmera
You could do something like keep the compile-time environment around and then try to fetch from there when you find-class later, but that's both dumb and a memory leak
14:50:42
beach
I think I can justify choice 1 by saying that the class created at compile time is indeed similar to the one that will be created at load time.
14:50:47
Bike
so if we're talking about compiling and loading in different images the classes are going to be "eq" pretty much automatically, but not in any spectacularly helpful way
14:51:10
Bike
for the case of compiling and loading in the same case, not being eq is probably fine, though.
14:51:39
Shinmera
Given that most implementations simply fail when trying to find-class at compile-time, I would wager there's absolutely no code out there that would rely on them being eq, so you'll be fine :)
14:52:06
beach
It is no worse than being similar if you make a load form for the compile-time class.
14:52:25
Bike
there is one thing. defclass is kind of vague about what information the compile-time class has to include. however, 3.2.2.3 says that "Classes defined by defclass in the compilation environment must be defined at run time to have the same superclasses and same metaclass." which could be interpreted as directing the behavior maybe.
14:52:41
Bike
except it's problematic because there's otherwise no reason for the metaclass to have to be fully defined at compile time
14:53:18
Shinmera
same metaclass is also awkward because it means the class needs to be initialised to a good extent
14:54:14
Shinmera
unless you can get away with having it not initialised, but simply returning the correct metaclass and typep relations
14:55:05
Bike
on the other hand, i can imagine a programmer wanting to be able to determine the class of a class at compile time
14:59:12
Bike
yeah, if you want to actually make an instance of the metaclass, it needs to be pretty well initialized
15:00:44
beach
The superclass in the starup environment will have a list of subclasses, including the one created in the compilation environment.
15:01:34
beach
So, actually, without any explicit action, the compile-time class is stored in the startup-environment anyway.
15:04:24
beach
Creating it a compile time is completely against the spirit of the rest of the standard. Functions, methods, etc, are not created at compile time.
15:07:16
heisig
I think what the spec wants to say is that type queries should work properly at compile time. Nothing more.
15:12:01
beach
Well, I guess my last objection is not specific to compilation though. Nothing prevents the programmer from doing (setf (find-class 'bla) nil) at run time and the class will still be a subclass of an existing class, yet can't be found in any other way.
15:23:12
heisig
CLHS 3.2.1 "It is unspecified whether a definition available in the compilation environment can be used in an evaluation initiated in the startup environment or evaluation environment."
15:28:01
beach
"The evaluation environment is a run-time environment in which macro expanders and code specified by eval-when to be evaluated are evaluated. All evaluations initiated by the compiler take place in the evaluation environment."
15:30:22
Shinmera
I mean, otherwise I would write "It is unspecified whether a definition available in the compilation environment can be used in an evaluation initiated in that environment"
15:31:09
Shinmera
Also, it doesn't make any sense to me to have a definition available, but not having it be usable at all? What qualifies a "use"?