[Prev][Next][Index][Thread]

Re: Need help with Class-Allocated Slots



Neel Krishnaswami wrote:
....
> The big problems with this that is it's hard to know what to do if
> there is a specialized method shadowing the basic getter. For example:

  What if there were a way to add to generic function the same method
  so that instance and class access use the same method. 

>define method foo (obj :: <perverse-subclass>, #next next-method)
>   obj.bar * next-method()
>  end method;

[By the way,   I'm not sure it is a good idea to allow this to be legal     
   (unless "bar" is also a class slot). If you can access a class slot
   without any instances the above is nonsensical. The compiler may
   be able to flag it as such but it would be a runtime error.  ] 

  So instead ( ignoring the syntax of the macro for the moment )

   define method foo ( obj :: <pervse-subclass>, #next next-method)
      ... body ... 
   end;
   define method foo ( obj == <perverse-subclass>, #next next-method)
      ... body ...
   end; 

  That way you'd use the same generic function to access the slot as 
  instance slots.  The  definition would just be irregular. Perhaps
  something like: 

  define class-slot-getter <peverse-subclass> foo  ( #next next-method)
       ... body ...
  end; 

  define class-slot-setter <peverse-subclass> foo ( new-value :: <integer>,
                                                    #next next-method )
       ... body ...
  end; 


Lyman



Follow-Ups: References: