[racket] Question about fields in Racket OO

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Dec 16 00:13:41 EST 2010

See define-local-member-name.


On Wed, Dec 15, 2010 at 10:38 PM, Mark Engelberg
<mark.engelberg at gmail.com> wrote:
> I'm playing around with the object-oriented subset of Racket, and have a
> couple of questions.
> Ideally, I'd like to equip a class with a field that is visible only to it
> and its subclasses.  As far as I can tell, though, this isn't possible.  It
> seems that I have to make a choice between a completely private field
> visible only to the class (by just using "define") or making a completely
> public field (by using "field").  Correct?
> Now, let's say I make the field public.
> In the subclass, how do I change the default value of field?
> For example, in the superclass, I might have
> (field [a 300])
> but in the subclass, I want to do something like
> (inherit-field [a 200])
> However, as far as I can tell, the syntax doesn't support anything other
> than
> (inherit-field a)
> Thanks,
> Mark
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.