[plt-scheme] Field names in the class system

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Sat Aug 1 11:04:25 EDT 2009

But doesn't that make the field public? Is there any way to do it
without making the field public?

On Sat, Aug 1, 2009 at 10:18 AM, Matthias Felleisen<matthias at ccs.neu.edu> wrote:
>
> Use init-field.
>
> On Aug 1, 2009, at 9:59 AM, Todd O'Bryan wrote:
>
>> How do I get the names I use when passing in values with new to match
>> the internal field names?
>>
>> In other words, I'd like to be able to do
>>
>> (new foo% [name "blah"])
>>
>> and then assign the field name the value "blah" inside the class.
>>
>> My first attempt was:
>>
>> (define foo%
>>  (class object%
>>    (init name)
>>
>>    (super-new)
>>
>>    (define name name)))   ; doesn't work because name is already defined
>>
>> I tried using the maybe-renamed construct, but the name is backwards
>> from what I expected:
>>
>> (define foo%
>>  (class object%
>>    (init (field-name name))
>>    ...)
>>
>> means that I have to do (new foo% [field-name "blah"]), rather than
>> [name "blah"].
>>
>> I'm sure I'm just missing something obvious...
>>
>> Todd
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.