OK, it works when the set! occurs after the super-new.  I didn&#39;t think set! would work at all in a class definition (as opposed to within a method); I was thinking of the whole system of defining classes as more of a declarative DSL that only allowed certain constructs.<br>
<br>Now that you point it out though, I see there is an example in the guide that does set! on an inherited field.<br><br>Thanks,<br><br>Mark<br><br><div class="gmail_quote">On Wed, Dec 15, 2010 at 9:53 PM, Robby Findler <span dir="ltr">&lt;<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">set!?<br>
<br>
Try it in both positions (the commented out one and the other one):<br>
the thing to keep in mind is that the declaration in c% is also kind<br>
of like a set! that happens when the object is initialized.<br>
<br>
Robby<br>
<br>
#lang racket<br>
(define c%<br>
  (class object%<br>
    (field [f 1])<br>
    (define/public (get-f) f)<br>
    (super-new)))<br>
<br>
(define d%<br>
  (class c%<br>
    (inherit-field f)<br>
    (set! f 2)<br>
    (super-new)<br>
    ; (set! f 2)<br>
    ))<br>
<br>
(send (new d%) get-f)<br>
<br>
On Wed, Dec 15, 2010 at 11:46 PM, Mark Engelberg<br>
<div><div></div><div class="h5">&lt;<a href="mailto:mark.engelberg@gmail.com">mark.engelberg@gmail.com</a>&gt; wrote:<br>
&gt; Thanks.  That seems to address the shared private issue.<br>
&gt;<br>
&gt; So is there a way to give a new value to an inherited field?<br>
&gt;<br>
&gt; --Mark<br>
&gt;<br>
&gt; On Wed, Dec 15, 2010 at 9:13 PM, Robby Findler &lt;<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; See define-local-member-name.<br>
&gt;&gt;<br>
&gt;&gt; Robby<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Dec 15, 2010 at 10:38 PM, Mark Engelberg<br>
&gt;&gt; &lt;<a href="mailto:mark.engelberg@gmail.com">mark.engelberg@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; I&#39;m playing around with the object-oriented subset of Racket, and have a<br>
&gt;&gt; &gt; couple of questions.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Ideally, I&#39;d like to equip a class with a field that is visible only to<br>
&gt;&gt; &gt; it<br>
&gt;&gt; &gt; and its subclasses.  As far as I can tell, though, this isn&#39;t possible.<br>
&gt;&gt; &gt; It<br>
&gt;&gt; &gt; seems that I have to make a choice between a completely private field<br>
&gt;&gt; &gt; visible only to the class (by just using &quot;define&quot;) or making a<br>
&gt;&gt; &gt; completely<br>
&gt;&gt; &gt; public field (by using &quot;field&quot;).  Correct?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Now, let&#39;s say I make the field public.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In the subclass, how do I change the default value of field?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; For example, in the superclass, I might have<br>
&gt;&gt; &gt; (field [a 300])<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; but in the subclass, I want to do something like<br>
&gt;&gt; &gt; (inherit-field [a 200])<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; However, as far as I can tell, the syntax doesn&#39;t support anything other<br>
&gt;&gt; &gt; than<br>
&gt;&gt; &gt; (inherit-field a)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Mark<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _________________________________________________<br>
&gt;&gt; &gt;  For list-related administrative tasks:<br>
&gt;&gt; &gt;  <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>