[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mon, 2 Sep 2002 11:33:12 -0500
Suppose I do this:
(define-record foo thing bar)
Now, when I make the record:
(make-foo 0 0)
I *have* to pass some initializations into make-foo.
My question is, is that necessary? It makes it complicated when I want
to make some foo objects, but don't yet know all of what is going to
go into it (or even care if all of the fields are used, even). Sure,
I could construct all of the fields in some let binding before calling
make-foo, but that is sort of annoying.
It would be nice if (make-foo) just returned an undefined record foo,
and the compiler at run time can do a check to see if I'm referencing
a method out of foo that I have not yet set!.
Well, that's the theory anyway, the run time checking could slow down the
implementation of the record, if that is the case I suppose you could return
the catchall #f during the lookup of an undefined method. It is the same thing
when looking up a nonexistant hash key in a hash table.
The place I'm using this is a symbol object for a compiler I'm writing,
specifically the typchecker. It turns out that the symbol has to contain
all possible things that any object in the compiled language can be, but
not all of them are important in any given situation. For now, I've recoded
the symbol object as a message passing style object so I don't have to
initialize all of the fields upon creation.
- [Chicken-users] records,
Peter Keller <=