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"?
15:35:30
beach
Let me tell you the real reason I am asking this: :) If the class is not created at compile time, then the compiler needs some other way (other than find-class) of getting the information about it. So then I must include a CLASS-INFO function and class in my improved environment protocol.
15:37:15
heisig
Shinmera: Environments are actually fine, given the amount of flexibility you have with CL.
15:37:57
beach
Environments started to make a lot more sense to me when I invented first-class global environments.
15:38:59
beach
Shinmera: They didn't make sense to me before first-class global environments, but when I re-read the Common Lisp HyperSpec with those in mind, it makes perfect sense.
15:39:46
beach
I mean, sure, if we didn't have multiple environments allowed by the Common Lisp HyperSpec, then the problem would also go away.
15:40:42
beach
To me, it makes perfect sense to want to compile a file while not having the compilation leave any traces in the startup environments.
15:41:07
beach
Bike: The environment protocol is not in the spec anyway, so no problem including it.
15:41:46
beach
Wow, this is exactly the kind of discussion that I like because I learn a lot from it.
15:42:44
Shinmera
Though I think the inclusion of CFASLs in SBCL makes me think there's plenty of software out there relying on those traces, or am I completely confused now?
15:42:52
beach
Anyway, conclusion for now: include CLASS-INFO in the improved CLtL2 section 8.5 protocol.
15:44:17
Shinmera
CFASLs encapsulate the compile-time side-effects, so that compilation can be paralellised without LOADing full FASLs, iinc
15:45:24
beach
So it's a strange way of creating separate compilation and evaluation environments that would nominally not be possible in SBCL?
15:45:27
Bike
e.g., the loading the cfasl of a file with defmacros and defuns in it will add the macros to your environment but not the functions
15:46:25
beach
Oh the amount of work people are willing to spend for not including my first-class global environments in their implementation. :)
15:52:09
jackdaniel
ACTION spent no work on not including beach's first-class global environments in my implementation
15:52:55
beach
I wish we had an "annotatable" version of the standard. Then, things like this could be put right there where it would be directly visible to everyone.
15:53:21
jackdaniel
I think no wider audience will be interested in the fact I spend no time on this ;-)
15:53:25
Shinmera
Reminds me of that todo item I have: a browser plugin that allows you to annotate arbitrary sites
15:54:00
beach
We could then start resolving issues like this with the purpose of ultimately creating WSCL.
15:54:59
beach
He just wanted a modern version of the Common Lisp HyperSpec and other Common Lisp documentation.
16:38:23
jcowan
Shinmera: Such arbitrary site annotators have been tried many times, but they are just a vehicle for spam
16:39:53
jcowan
The principle is: if you are not within the (possibly small) organization that is (held) responsible for a site, then anything you can upload to the site cannot be downloaded from the site by anyone outside that organization without approval from the organization.
16:40:19
jcowan
$FORMER_EMPLOYER got into repeated trouble with Google by breaching this principle: people would upload phishing spams and get the whole site blocked.
16:42:16
beach
I wouldn't mind having someone manually check each annotation. There are not going to be tons of them.
16:50:43
Shinmera
for the purposes of a clhs/etc annotation, a read-only-by-default model would be just fine.