[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setter problem



At 11:35 AM 10/26/92 -0800, thant@void.esd.sgi.com wrote:
> Why doesn't this work?
> 
> 
> (define-class <foo> (<object>)
>   (a)
>   (b))
> ;Value: <foo>
> 
> (define foo (make <foo>))
> ;Value: foo
> 
> ((setter a) foo "apple")
> ;Value: "apple"
> 
> ((setter b) foo "ball")
> ;Value: "ball"
> 
> (define-method see-foo (m (f <foo>))
>   (m f))
> ;Value: see-foo
> 
> (see-foo a foo)
> ;Value: "apple"
> 
> (see-foo b foo)
> ;Value: "ball"
> 
> 
> (define-method set-foo (m (f <foo>) i)
>   ((setter m) f i))
> ;Value: set-foo
> 
> (set-foo a foo "aardvark")
> ;Error: unbound variable dylan:setter/m/

This doesn't work because setter isn't a function.  The definition
of set-foo uses a variable

   (setter m)

Of course, there is no such variable.  Your program acts as if setter
is a function which takes one function and returns another, which is
not the case.  Setter is syntax.

We're considering changing setter syntax so that it doesn't look so
much like an operation.  Your mistake probably wouldn't have come up
if (setter a) were spelled set-a.

  -Andrew