[racket-dev] [racket] Question about fields in Racket OO
On Thu, Dec 16, 2010 at 12:22 AM, Mark Engelberg
<mark.engelberg at gmail.com> wrote:
> OK, it works when the set! occurs after the super-new. I didn'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.
You've probably already figured this out, but the body of a class is a
series of definitions and expressions like at the top-level but
'define' taking on the meaning of 'make a field', and a bunch of new
definitions appearing. The new stuff says what the methods are, but
everything else is just executed in sequence as if it were in the body
of the initializer (if this were in Java, say).
hth,
Robby