better setter syntax? 
Author Message
 better setter syntax?

I'm struggling to understand setter syntax.  (Reminiscent of my
reaction to 'Eraserhead'--I keep waiting for something familiar
to happen.)  There's gotta be a simpler, more intelligible
way to present this.  I remember reading in an insert (included in
the copy of dylan text I got from Apple) a promise to provide
better setter syntax.  Has anyone delivered on this promise yet?
What might be some alternative syntaxes?

--Larry



Sun, 07 Jan 1996 07:00:50 GMT  
 better setter syntax?

Quote:
>I'm struggling to understand setter syntax.

Recently, I've been using Kenneth{*filter*}ey's YASOS object system
for Scheme.  It includes something with a syntax much like the
original Dylan setter syntax.  This gave me an idea about what in
the world lead the Dylan designers to start with that setter
syntax--variables that look like lists.  I haven't really used
this aspect of Yasos or worked through the code, but I think that
the idea is that in Yasos the getter is a function which either
returns the contents of the object slot, or else returns a setter
function.  So

(<getter-name> <object>)

will return the value of the slot associated with that getter, while

(setter <getter-name>)

will return a setter function which can be used to set the value
of the same slot.  Thus in

((setter <getter-name>) <object> <new-value>)

"(setter <getter-name>)" will evaluate to the setter function,
which is then applied to the object and the new value, thereby
setting the slot to the new value.

*This* makes sense to me.  It's one of those nifty Scheme tricks
that I find fascinating.

But making

(setter <getter-name>)

into a variable is really confusing.

Anyway, my theory is that originally the Dylan designers had in
mind something like the way setters work in Yasos (this is
probably a traditional Scheme device that Yasos just made use
of).  But then the designers decided that setters should be
variables instead of function calls (I suppose it's more
efficient at run time), and they just made the setter function
call syntax into a variable name.  And by the time the manual was
written, there was no reference to the original idea behind the
setter syntax, so it was confusing to people like you and me.
(Note that I'm not trying to dump on the Dylan designers.  The
way the original setter syntax worked seems like a mistake (one
that's been corrected) but if you can't have mistakes when you're
developing something, then you'd better possess inhuman genius.)

Quote:
> .... I remember reading in an insert (included in
>the copy of dylan text I got from Apple) a promise to provide
>better setter syntax.  Has anyone delivered on this promise yet?
>What might be some alternative syntaxes?

Somewhere I read that the new syntax is:

        GETTER                  SETTER
        window-position         window-position-setter
        table-size              table-size-setter
        window-color            window-color-setter

Marshall Abrams



Wed, 10 Jan 1996 02:50:58 GMT  
 better setter syntax?

Quote:
>I haven't really used
>this aspect of Yasos or worked through the code, but I think that
>the idea is that in Yasos the getter is a function which either
>returns the contents of the object slot, or else returns a setter
>function.

This is essentially correct.

Note that
        (set <getter-name> <object> <selector>... <new-value>)
expands to
        ((setter <getter-name>) <object> <selector>... <new-value>)

i.e. (set (vector-ref v 3) 37) => ((setter vector-ref) v 3 37), where the
value of (setter vector-ref) is the value of vector-set! .

Quote:
> making

>(setter <getter-name>)

>into a variable is really confusing.

The YASOS interface was based on T's locatives.  Dylan's setter is a name
making macro.  The only way to think about it is that they are different.
{It confused me at first too}.  The disadvantage of YASOS's implementation
is the runtime cost of the procedure call & dispatch to evaluate the setter
form.  As Dylan was designed to be a product delivery language, this is not
necessarily a bad trade off.  You do have to think about it differently
though.

-Ken



Wed, 10 Jan 1996 05:00:25 GMT  
 better setter syntax?

I thought that one of the Dylan people at Apple would pop up to answer
this, but I guess they're busy right now with other things.

On cambridge.apple.com, in directory /pub/dylan/design-notes, there are
FTP'able files that describe a set of changes to the Dylan language that
have been decided upon (though I suppose no such decision is etched in
stone right now).  One of these design notes describes the new improved
setter syntax.


        GETTER                  SETTER
        window-position         window-position-setter
        table-size              table-size-setter
        window-color            window-color-setter

Just so.  This is now simply a naming convention.

I think that the original syntax was intended to be a function that gets
the getter function, as people have speculated.  This idea was abandoned
in part because it made it difficult for a module to export a setter
without exporting the corresponding getter (or the means for getting it).
Modules provide access control only for symbols, so the getter-getters had
to become funny looking symbols.  But that was terribly confusing, so now
they are normal-looking symbols.

-- Scott

===========================================================================

Senior Research Scientist               Phone:     412 268-2575
School of Computer Science              Fax:       412 681-5739
Carnegie Mellon University              Latitude:  40:26:33 N
5000 Forbes Avenue                      Longitude: 79:56:48 W
Pittsburgh, PA 15213
===========================================================================



Wed, 10 Jan 1996 10:44:26 GMT  
 better setter syntax?

Oops, let me try that last paragraph again:

I think that the original syntax was intended to be a function that gets
the setter function, as people have speculated.  This idea was abandoned in
part because it made it difficult for a module to export a getter without
exporting the corresponding setter (or the means for getting it).  Modules
provide access control only for symbols, so the setter-getter forms had to
become funny looking symbols.  But that was terribly confusing, so now the
setters are just normal-looking symbols.

Everyone clear now?

-- Scott

===========================================================================

Senior Research Scientist               Phone:     412 268-2575
School of Computer Science              Fax:       412 681-5739
Carnegie Mellon University              Latitude:  40:26:33 N
5000 Forbes Avenue                      Longitude: 79:56:48 W
Pittsburgh, PA 15213
===========================================================================



Wed, 10 Jan 1996 14:09:36 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Setter Syntax

2. Design notes (setter syntax)

3. Implementing letrec-syntax using only let-syntax and syntax-rules

4. Is Property Syntax Better?

5. C syntax better than c++ ?

6. wanted: good SML syntax for monadic style

7. Better Dylan syntax?

8. Better Dylan syntax?

9. The GOOD IDEA (was: Syntax metalanguage vs end if)

10. the better syntax?

11. BRL 2.2: better input validation and other improved syntax

12. Any Good Syntax Checkers ?

 

 
Powered by phpBB® Forum Software