freenode/#sicl - IRC Chatlog
Search
4:42:02
beach
Yesterday I tried something new and I will continue that experiment today and perhaps a bit longer. This may sound alarming, but here goes....
4:43:18
beach
For example, now, my bridge CLASSES are in environment E2, and my bridge GENERIC FUNCTIONS are in E3.
4:43:42
beach
It is hard to understand, and I wanted to know whether it would be harder to keep them in the same environment.
4:44:24
beach
Doing it over is not as scary as it sounds. Now I know a lot more about what is needed and when, and I know a lot more about sharing code between phases.
4:45:22
beach
Yesterday, I finished phase 1 in this rewrite. If phase 2 turns out to be fairly fast to write, I think I will go with this new system.
4:46:39
beach
I should not hesitate splitting up functions in the CLOS module into smaller ones. That way, I can replace smaller amounts of code at bootstrapping time if I need to.
4:47:49
beach
And I should not hesitate introducing an indirection, so that a function calls another function when needed. An example: FIND-CLASS. During bootstrapping, different calls to FIND-CLASS mean different things.
4:48:17
beach
For instance, when I create a class metaobject, it has to find both the metaclass and the superclasses.
4:49:26
beach
So I introduce two functions FIND-METACLASS and FIND-SUPERCLASS. In production code, they both just call FIND-CLASS.
4:49:50
beach
But during bootstrapping, they are two small pieces of code that I can redefine as I wish.
4:50:43
beach
These "ideas" (that I should have realized a long time ago, but hey) make it possible to reuse more production code during bootstrapping, so the total amount of bootstrapping code decreases.
4:52:14
beach
no-defun-allowed: You seem to become interested in how Common Lisp is implemented. If so, you might want to peek at the SICL specification from time to time.
4:53:45
no-defun-allowed
(this vacuum cleaner is very good at getting cat hair stuck in it. i would not reccomend you give it to cat people.)
4:54:46
beach
I don't have a cat, and I have a cleaning lady and two very good vacuum cleaners, so I think I am set.
4:55:06
beach
So, SBCL is a bit strange with its representation. In the distant past, someone thought that CAR and CDR would be used a lot, so it would be a win to avoid having to check for NULL and CONS each time.
4:55:42
beach
So the bright idea in SBCL (probably already in CMUCL) was to make NIL look like a CONS when it comes to the low tags.
4:57:53
beach
If they had represented NIL as just another symbol, it would have been a simple matter of testing for the CONS low tag in each iteration.
4:58:33
beach
Testing for whether the end is NIL or some other atom is only needed at the end of the list.
4:59:41
beach
Now that cleaver idea in SBCL now penetrates all over the code as a special case, which, in addition, is no longer an optimization, because traversing a list takes longer, and CAR/CDR has been replaced by generic-function accessors for data structures.
5:01:00
beach
Either that's all there is to it (if it is a CONS), or the second word points to a "rack".
5:03:08
beach
Now, everything gets simpler to write. SICL itself, of course, but also things like the inspector, the garbage collector, etc.
5:05:03
beach
000, 010, 100, and 110 are all for fixnums, just like for SBCL and other Common Lisp implementation.
5:07:33
beach
111 is for pointers to rack. Not really needed, but comes in handy for the GC. Racks are not first-class objects, so they can't be the value of a variable etc.
5:09:04
beach
Either way, if you know you have a CONS cell, CAR and CDR turn into a single instruction for each one.
5:11:03
beach
There might have been a slight advantage to use 001 and 011 for CONS cells and general instances, because then 0x1 means a heap-allocated object. But I don't think it matters.
5:12:08
beach
Ether way, none of that matters for SICL because there is no C or assembly file in which these tags are defined.
5:14:12
beach
There might be some code in SICL right now that mentions those tags, but that code is obsolete. It will be removed when I get around to it.
5:18:37
beach
Interestingly, as you probably know, in SICL each class has a UNIQUE NUMBER which changes when the class is redefined. One might think that some of those class numbers, like for STANDARD-CLASS etc., would have to be mentioned somewhere.
5:18:37
beach
Not so. They get assigned during bootstrapping, and they acquire the same number in each phase. So, in the last phase, all I need to do is to define a constant that takes the value of a class number in the previous phase, should I need such a thing. But I don't think I even need it at all.