[bitc-dev] Facet pointers (aka interfaces)
Jonathan S. Shapiro
shap at eros-os.org
Fri Jan 28 21:42:57 EST 2005
Oh boy do I owe Constantine an apology! Just goes to prove that too much
coffee and too little sleep can make you really really stupid! Also
So first, Constantine is right. We need something like what he is
calling "facets." As I thought about I/O today, I realized (a) why we
need them and (b) that we already have them (sort-of).
For all externally observable purposes, a facet is simply a structure
all of whose member fields are procedures. For example:
get : (fn () char)
put : (fn (char) ()))
We can instantiate this using something like the following:
(local ((define repr-state (make-stream-state))
(trivstream (lambda () body-returning char)
(lambda (char) body-consuming-char)))
If this corresponds behaviorally to what Constantine means by facets
(does it?) then I see two remaining issues:
1. Should there be a convenience syntax for this? [I am coming to
dislike LOCAL, but that is a side issue].
2. Should facets differ from structures by creating a vtable-like data
structure, on the theory that the method table might grow large and can
be shared? That is, where the actual object was a struct of the form
(defstruct (facet-rep 'a)
state : 'a
methods : (struct-containing-methods 'a))
the only difference between this and the structure form would be
implicitly performing the insertion of the arguments.
For the moment, I think that the right thing to do is do this using
structures until we have a better sense of what we need.
More information about the bitc-dev