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

Re: perhaps I've missed something ...

John Clements <clements@xxxxxxxxxxx> writes:

> ... but I fail to see the appeal of this mechanism. As far as I can 
> tell, a scheme implementation which conforms to this SRFI allows me 
> to write
> (set! (car x) 5)
> rather than
> (set-car! x 5)

The issue is that set-car! requires introducing a new primitive
concept, with a new name, that you have to learn and remember.  Yes,
it's easy enough to deal with, thanks to naming conveptions.  But
I would much rather have 50 names for getter+setter procedures
vs 100 names for separate getter and setter procedures.  For one
thing, the latter clutters up manuals and reference cards more!

> To my eyes, the only effect of this change is to confuse the 
> primitive which mutates bindings (set!) with a primitive that mutates 
> values (set-car!).  Although these two are radically different 
> beasts, beginning students often find it hard to understand the 
> difference, and a change of this sort will only make it harder to 
> teach them.

First, most "beginning students" actually have experience with
languages (such as C or Java) that are more like the proposal.
Secondly, I think you're wrong about the distinction; they are
not radically different beasts.  Semantically:
        (set! x v)
is arguably syntactic sugar for:
        (set! (the-evironment 'x) v)

> ps. Since I am using a fixed-width font, I can see that the second 
> one is actually two characters shorter.

But that's hardly the point, is it?  If we were into counting
characters, we'd be using APL (or J or C).  The point is economy
of concepts.

> pps. let and letrec are both binding constructs. I don't see why we 
> need two different forms.  Why not just use 'let,' and if any of the 
> right-hand-sides happen to refer to the name they're bound to, 
> implicitly change the whole thing into a letrec?  I think this would 
> be much simpler and avoid lots of confusion.

Sarcasm aside, I agree, sort of.  Having `let', `let*', `letrec'
*plus* internal `define' is overkill.  My advice for anyone designing
a new language would be to drop `let', `let*', and `letrec' and just
keep some variant of internal `define', which of course is basically
syntactic sugar on top of `letrec'.  (For the very rare case that one
might actually need `let' or `let*', use `lambda'.)
	--Per Bothner
per@xxxxxxxxxxx   http://www.bothner.com/~per/