[plt-scheme] same names for class.ss init-fields and methods

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 26 10:23:34 EST 2003

At Wed, 26 Mar 2003 10:09:59 -0500, "Neil W. Van Dyke" wrote:
> In `class*' syntax, is there a way to define public methods that have
> the same names as initialization fields?

Yes. The init var and method must have different internal names,
though.

Generally, replace a single name with `(internal-name external-name)'
to make the internal and external names different.

 (class object%
    (init ((local-foo foo) 17))
            ; ^        ^    ^--- default value
            ; |         `---- external name
            ;  internal name
    ...)

Matthew



Posted on the users mailing list.