[cells-devel] Re: It's not a feature, it's a bug

Kenny Tilton ktilton at nyc.rr.com
Fri Nov 7 08:09:25 UTC 2003



Thomas F. Burdick wrote:

>Kenny Tilton writes:
> > 
> > Thomas F. Burdick wrote:
> >
> > >  (defclass foo () ((a :accessor foo-a :type fixnum)))
> > >
> > >and if you try to set an A slot to something other than a fixnum,
> > >you'll get a runtime error. 
> >
> > Good lord. Do they know CL is short for Common Lisp? Tell me they get 
> > huge runtime performance benefits from this sacrilege.
>
>(What about "Steel Bank" says "fast and loose"? ;) Taking the CL type
>system seriously has a few benefits, one of which is can be being able
>to emit blazingly fast object code, but a big one is debugability.
>
gotcha.

> > Actually, there is a problem here. Currently Cell structures land in the 
> > slot during make-instance ...
>
>Well, right now, any value can actually go in a slot with a declared
>type: type checking only happens if you go through the accessor
>method.  
>
Oh, right, you said that. I thought I heard a concern that nil could not 
be a NULL-VALUE for a slot with an explicit numeric type specified. Oh, 
well, still a good idea to capture type info for the accessors Cells writes.

>Cells-for-structures wouldn't work so hot, though.
>
> > Well, we'll put this in the hopper, but I propose we give higher 
> > priority to me documenting the system and getting Cello going.
>
>Definately.  I'm partly just bouncing ideas off of you, and if they
>seem workable, I'll make the changes myself, if I need them.
>
The marines have landed!

>
> > And I 
> > think I do want to make the resumed base value (what /do/ we call that?) 
>
>an at-rest value?
>
Not bad. I had toyed with quiesce-to.... restore-to? stable-value? 
fallback-value?

>
> > of an ephemeral a distinct attribute, so as not to shadow the semantics 
> > of an instance being initialized with an ephemeral slot initialized, 
> > say, (CV 2) with baseline value zero.
>
>Okay, so the initial value would be just another value it takes on
>ephemerally, before going back to its resting state?
>
Yep. the only problem is that I would have to arrange for ephemrals 
initialized this way to hang on to non-resting values until all other 
cells (in all instances being awakened in one batch) had been kicked 
off, because at make-instance time (well, at TO-BE time) the sytems has 
not stabilized with all dependencies in place, so an ephemeral does not 
know who to notify.

This is getting ugly. I think I'll go with resting-value because as a 
rule I like explicit, then wait for initialization to non-resting to 
come up a again so I can think more clearly about the problem.

>
> > >  STYLE-WARNING: redefining SHARED-INITIALIZE :AFTER (FOO T) in DEFMETHOD
> >
> > Hey, SBCL is creating an after method on shared-initialize?
>
>Oops, that was TFB that did that, not SBCL.
>
whew! but then we have a problem? Oh, I see, just that dumb check that 
someone does not use defmodel then specify superclasses, none of which 
inherit from model-object. I wonder if that is necessary? They'll find 
out soon enough (tho it could take a while to figure out. )

>
> > >  5368709110
> > >  * (typep * 'fixnum)
> > >  
> > >  NIL
> >
> > Gee, what /is/ the type?
>
>Too much?  Actually, the answer is kind of amusing.  CMUCL would tell
>you BIGNUM.  SBCL, however, is a tiny bit more precise:
>
>  * (type-of 5368709110)
>  
>  (INTEGER 536870912)
>
>Did I mention they take the type system seriously?
>
> > >In reverse order of simplicity, the best way to solve this would be to
> > >fix SBCL; 
> >
> > Have you asked the SBCL crowd whether they are set on slot-value being 
> > type-ignorant?
>
>I'd assume just the opposite, that they consider it a bug (it seems
>like a gap in declarations-as-assertions), but I don't see it in the
>BUGS file, so maybe I'm wrong.  I'll ask.
>
> > >the second best way would be to either have Cells use
> > >:around methods, instead of redefining the primary methods, then
> > >invoke the proper next-method machinery 
> >
> > That scares me.in the abstract, tho I cannot point to any evil 
> > consequence, I just think one will arise in due course because it 
> > strikes me as a kluge.
>
>Ooh, yeah, that might do bad things if you have one model that
>inherits from another (the next-method would be the superclass'
>:around method).
>
> > >-- or, have Cells propagate
> > >the type declaration to its new method definitions.  
> >
> > That should be easy, and sounds Deeply Correct. I am already looking at 
> > the slot definition name to get reader and writer names, may as well 
> > grab the type if any. So what's the syntax for declaring a /return/ 
> > type? And the synatx on the setf side as well.
>
>This seems like a good thing for Cells to do, because that way type
>declarations can more fully do their thing, whatever that means on the
>implementation you're using.  For syntax:
>
>  * (macroexpand-1
>     '(defmodel foo ()
>        ((x :initform (cv 0) :accessor get-x :type fixnum)
>         (10x :cell t :accessor get-10x :type fixnum))))
>  
>...
>
>    (PROGN
>     (DEFMETHOD GET-X ((SELF FOO)) (CELLS::MD-SLOT-VALUE SELF 'X))
>     (DEFMETHOD (SETF GET-X)
>                (NEW-VALUE (SELF FOO))
>                (SETF (CELLS::MD-SLOT-VALUE SELF 'X) (COERCE NEW-VALUE 'FIXNUM)))
>     NIL)
>
>(Holy crap, where'd that COERCE come from?  That's not a good idea at
> all, you can lose object identity that way.)
>
>With type declarations, that would be:
>
>    (progn
>     (defmethod get-x ((self foo))
>       (declare (values fixnum)) ; <====
>       (cells::md-slot-value self 'x))
>     (defmethod (setf get-x) (new-value (self foo))
>       (declare (type fixnum new-value))
>       (setf (cells::md-slot-value self 'x) new-value))
>     nil)
>
>Problem is, the type-checks don't go deeply enough into cells this
>way.  If we propagage the type declarations for 10X in the same way,
>we get:
>
>    (progn
>     (defmethod get-10x ((self foo))
>       (declare (values fixnum))
>       (cells::md-slot-value self '|10X|))
>     (defmethod (setf get-10x) (new-value (self foo))
>       (declare (type fixnum new-value))
>       (setf (cells::md-slot-value self '|10X|) new-value))
>     nil)
>
>But when X is changed, and 10X is recalculated, this method doesn't
>get invoked.
>
If DEFMODEL stuffs type info by slot and class into some global hash or 
property list, at make-instance time we can pull the type info into a 
dedicated slot in the cell structure. would that help in anyway? Looks 
like THE cannot use a dynamic type.

Hey, I put in the serialize option and now ASDF compiles but does not 
load (until the end I guess), so later compiles don't see earlier stuff. 
(Some serial!) . I tried coding up:

   :perform (compile-op :after (op c)
                            (load c))

but i was just guessing wildly. What's the incantation to get ADF to 
load as it goes?

kt

-- 
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film 

Your Project Here! http://alu.cliki.net/Industry%20Application






More information about the cells-devel mailing list