[plt-scheme] Field names in the class system

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Sat Aug 1 12:47:36 EDT 2009

Sorry, my mistake.  The internal name comes first.  The init
declaration should be:

(init ([other-name name] 'default))

See the documentation for class* to get the whole grammar for init declarations:


Carl Eastlund

On Sat, Aug 1, 2009 at 11:34 AM, Todd O'Bryan<toddobryan at gmail.com> wrote:
> Are you sure? Just trying to run this code
> (class object%
>  (init ([name other-name] 'default))
>  (define name other-name))
> causes the error
> class: duplicate declared identifier in: name
> Todd
> On Sat, Aug 1, 2009 at 11:08 AM, Carl Eastlund<carl.eastlund at gmail.com> wrote:
>> If you want a private field with the same name as an initialization
>> argument, you want to give the initialization argument a different
>> internal name.  It should work something like this:
>> (class
>>  ...
>>  (init ([name other-name] default))
>>  (define name other-name)
>>  ...)
>> You can leave out the default value, but you still need the extra
>> layer of parentheses that distinguish other-name from default.
>> --Carl

Posted on the users mailing list.