This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Syntatic sugar and identifier permissivity
- To: Lalo Martins <lalo at hackandroll dot org>
- Subject: Re: Syntatic sugar and identifier permissivity
- From: Marius Vollmer <mvo at zagadka dot ping dot de>
- Date: 04 Apr 2000 20:24:44 +0200
- Cc: guile at sourceware dot cygnus dot com
- References: <20000403213207.E4496@hackandroll.org>
Lalo Martins <lalo@hackandroll.org> writes:
> Actually most of OOP itself is syntatic sugar :-) so I'd like to
> request some sweetening of GOOPS. Get any character which is not
> valid in an identifier acording to r[45]rs; the comma would be
> specially good for that. Then use this as a special accessor syntax,
> so that
>
> (print foo,bar)
Currently, you would write this as
(print (bar foo))
I think that a special syntax for this would be bad, actually. One
nice feature of accessors is that they _are_ just functions and that
you use them as functions. You can turn a slot into a function that
computes the value or vice versa without having to go thru all your
code.
I do agree, however, that convenience is an important thing. A while
ago, I boasted about how happy I am to use long names for my accessors
because that way I could keep the interfaces of my objects clean and
separate. I have used GOOPS more in the meantime, and those long
names are getting more and more inconvenient.
Nevertheless, I think I can get enough convenience from
with-accessors. I use a macro to generate long accessor names, and a
macro can help me avoid having to type them in everytime.
I don't like that a simple C statement like
obj->x++;
turns into
(set! (gto-canvas-x obj) (1+ (gto-canvas-x obj)))
with my style of choosing accessor names, but I hope to write this
like
(with-struct-accessors ((gto-canvas x obj))
(set! x (1+ x)))
in the future. If you regard the `with-struct-accesors' line as
analogous to a (unavoidable) type declaration of obj in C, this is not
at all bad.
So to summarize: I don't think we should change the syntax of Guile to
make accessors different from other functions. However, there should
be enough hooks into the reader to let people bend the syntax quite
badly if they want to.