[plt-scheme] inheritance of private fields?

From: tom sgouros (tomfool at as220.org)
Date: Fri Feb 29 09:47:06 EST 2008

Matthias Felleisen <matthias at ccs.neu.edu> wrote:

> 
> Take a look at the paper at
> 
>  http://www.ccs.neu.edu/scheme/pubs/#aplas06-fff
> 
> It shows how to generate "private" names that you can share in a way
> that's analogous to protected in Java but you can choose the
> restriction policy via lexical scope.

Thank you for the help, and I'm sorry to be so dense, but I've been
looking at that paper for about half an hour, and I don't see which part
is applicable.  You're not talking about the generate-member-key
business are you?  Can you be more specific, please?

My apologies,

 -tom

> 
> 
> On Feb 29, 2008, at 7:45 AM, Tom Sgouros wrote:
> 
> >
> > Hello all:
> >
> > I want to define a general class with some private fields that can be
> > used by subclass.  Here's a dumb example of what I thought would be
> > the
> > right way to do this, but apparently isn't:
> >
> > (define size%
> >   (class* object% ()
> >     (public print-name print-age print-weight)
> >
> >     (init-field (name 'Fred) (bday 070661)))
> >
> >     (define age (calculate-age bday))
> >     (define weight 0)
> >
> >     (define print-name (display name))
> >     (define print-age (display age))
> >     (define print-weight (display weight))
> >
> >     (super-new)))
> >
> > Now I want to be able to define a sub-class of this, so that age and
> > weight are available to definitions in that sub-class.  I haven't been
> > able to do that, so feel I must be missing something.
> >
> > In the example age is a calculated value that depends on other
> > init-field values.  I'd make it public by putting it into the init- 
> > field
> > sequence, if there's a guarantee that the init-field entries are
> > processed in order (that it's a let* and not a let).  I can't find any
> > such guarantee in the documentation.  Failing that, what should I
> > do to
> > make it available?
> >
> > The weight private field should have no default value, but is intended
> > to be given one by the sub-class.  In my class-naif view of these
> > things, I should really make size% an interface and force the sub- 
> > class
> > to fill in the weight.  But I can't seem to figure out how to do that,
> > either.
> >
> > Can someone explain to me the proper way to deal with these  issues?
> > Any
> > advice welcome.
> >
> > Many thanks,
> >
> >  -tom
> >
> > -- 
> >  ------------------------
> >  tomfool at as220 dot org
> >  http://sgouros.com
> >  http://whatcheer.net
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 


-- 
 ------------------------
 tomfool at as220 dot org
 http://sgouros.com  
 http://whatcheer.net


Posted on the users mailing list.