[plt-scheme] it's class.ss night, tonight...

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 3 08:18:34 EST 2004

At Tue, 2 Mar 2004 20:40:41 -0800, briand at aracnet.com wrote:
> In the docs I read :
> 
>     Furthermore, within a single class, a single name can be used as
>     an external method name, an external field name, and an external
>     initialization argument name.
> 
> Cool - that's what I want to do _exactly_.  I want the field name to
> be foo, the accessor method foo and the external initialization name
> to be foo.
> 
>     Overall, the set of all internal variables must be distinct, and
>     set of of external variables must be distinct for each of the
>     method, field, and initialization-argument categories.
> 
> Hey wait a minute.  Doesn't this now tell me I can NOT do what the
> first sentence said I could do ??

The last part should say "Each internal variable must be distinct from
all other internal variables, each external method name must be
distinct from all other method names, each external field name must be
distinct from all other field names, and each initialization-argument
name must be distinct from all other initialization-argument names".

> Further evidence that it doesn't work is the duplicate declared
> identifier errors I keep getting.

You're using different internal and external names, right?

 (define foo%
   (class object%
     (init [(foo-init foo)])
     (field [(foo-field foo) 2])
     (public (foo-method foo))
     (define (foo-method) 3)
     (printf "Init was ~a~n" foo-init)
     (super-new)))

 (define foo (new foo% [foo 1]))
 (printf "Field is ~a~n" (get-field foo foo))
 (printf "Method is ~a~n" (send foo foo))

Matthew



Posted on the users mailing list.