From: William James Date: 2006-07-25T08:30:05+09:00 Subject: Re: RLisp - Lisp naturally embedded in Ruby Tomasz Wegrzanowski wrote: > On 7/24/06, William James wrote: > > > ; Configure the server > > > (let config [Hash new]) > > > > Please don't use "let" for this. "setq" or "define" > > would be much better. > > Now I know perfectly well that let is used in different way in other > dialects of Lisp ;-), but I think this is way nicer. And it's less cryptic > than setq (a big win); In newLisp, (setq x 9) is equivalent to (set 'x 9). The q is for 'quote'. So it's really not cryptic. 'let' means 'allow', so it's quite cryptic; what are we allowing? With your 'let' you are doing something different than all other Lisps are doing with 'let', so you should give it a different name. By using the same name, you are creating confusion and making it more difficult to port code between other Lisps and yours. You are making it more certain that the only people who will use your Lisp are people who know no other Lisp. Is that what you want? Do you think that your Lisp is so magnificent that people will abandon all others and use only yours? If you would keep the semantics of your Lisp as similar as possible to the semantics of other Lisps, you would make it easier for others to learn it and, having learned it, to remember it. When Matz added features to Ruby from other languages, he tried to keep the original names. Consider Ruby's inject; it does the same thing as Smalltalk's inject. If it didn't, a Smalltalk programmer using Ruby would continually have to remember that he is dealing with a peculiar, nonstandard inject and not with the widely known, original inject. Changing the meaning of existing words may satisfy your inner urges, but it helps nobody else. > define is a bit too long, but the main problem is > that it suggests global assignment, while (let x y) in RLisp rebinds > x in local environment. Local environments are introduced > by lambda/defsyntax, but I guess RLisp should also provide explicit > (local ...) > > So you can compute let's say length of a vector using: > (lambda (x y) > (let x2 (* x x)) > (let y2 (* y y)) > (let z2 (+ x2 y2)) > (sqrt z2) > ) You need 3 lets. newLisp needs only 1 letn. (define (vlen x y) (letn ( x2 (* x x) y2 (* y y) z2 (+ x2 y2)) (sqrt z2))) > > I find it a lot more readable than Scheme's: > (lambda (x y) > (let ( > (x2 (* x x)) > (y2 (* y y)) > ) > (let ( > (z2 (+ x2 y2)) > ) > (sqrt z2) > ) > ) > ) But that's not the best way to do it in Scheme. (define (vlen x y) (let* ( (x2 (* x x)) (y2 (* y y)) (z2 (+ x2 y2))) (sqrt z2))) One let* does the work of three of your lets.