[plt-scheme] Field names in the class system

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Sat Aug 1 15:03:27 EDT 2009

That did it. I actually read the docs and misread them in the same way
you misremembered them.

Thanks!

On Sat, Aug 1, 2009 at 12:47 PM, Carl Eastlund<carl.eastlund at gmail.com> wrote:
> 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:
>
> http://docs.plt-scheme.org/reference/createclass.html#(form._((lib._scheme/private/class-internal..ss)._class*))
>
> 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.