This seems like a trivial point because the class system doesn't have to track these things and they are in fact part of the closures of the methods, so I don't see in what sense they are "fields". Perhaps I am blinded by my reading of the implementation. I certainly agree they are essentially fields, but I can't but think of them as closed-over variables.<div>
<br></div><div>Jay<br><br><div class="gmail_quote">On Thu, Dec 16, 2010 at 7:00 AM, Carl Eastlund <span dir="ltr"><<a href="mailto:cce@ccs.neu.edu">cce@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
To quote the class* documentation:<br>
(<a href="http://docs.racket-lang.org/reference/createclass.html#%28part._clfields%29" target="_blank">http://docs.racket-lang.org/reference/createclass.html#%28part._clfields%29</a>)<br>
<br>
"Each field, init-field, and non-method define-values clause in a<br>
class declares one or more new fields for the class. Fields declared<br>
with field or init-field are public."<br>
<br>
So only the public ones are accessible via get-field.<br>
<font color="#888888"><br>
Carl Eastlund<br>
</font><div><div></div><div class="h5"><br>
On Thu, Dec 16, 2010 at 8:56 AM, Jay McCarthy <<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>> wrote:<br>
> Does 'define' really mean 'make a field'? I thought fields had to be<br>
> specially designated so that get-field would know about them...<br>
> Yes, this program errors:<br>
> #lang racket<br>
> (define c%<br>
> (class* object% ()<br>
> (field [x 1])<br>
> (define y 2)<br>
> (super-new)))<br>
> (define o (new c%))<br>
> (field-names o)<br>
> (get-field x o)<br>
> (get-field y o)<br>
> --<br>
> I agree that 'define' is like making a field, but fields are something<br>
> special too.<br>
> Jay<br>
> On Thu, Dec 16, 2010 at 6:51 AM, Robby Findler <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>><br>
> wrote:<br>
>><br>
>> On Thu, Dec 16, 2010 at 12:22 AM, Mark Engelberg<br>
>> <<a href="mailto:mark.engelberg@gmail.com">mark.engelberg@gmail.com</a>> wrote:<br>
>> > OK, it works when the set! occurs after the super-new. I didn't think<br>
>> > set!<br>
>> > would work at all in a class definition (as opposed to within a method);<br>
>> > I<br>
>> > was thinking of the whole system of defining classes as more of a<br>
>> > declarative DSL that only allowed certain constructs.<br>
>><br>
>> You've probably already figured this out, but the body of a class is a<br>
>> series of definitions and expressions like at the top-level but<br>
>> 'define' taking on the meaning of 'make a field', and a bunch of new<br>
>> definitions appearing. The new stuff says what the methods are, but<br>
>> everything else is just executed in sequence as if it were in the body<br>
>> of the initializer (if this were in Java, say).<br>
>><br>
>> hth,<br>
>> Robby<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>"The glory of God is Intelligence" - D&C 93<br>
</div>