From: Ola Bini Date: 2006-07-25T15:28:46+09:00 Subject: Re: RLisp - Lisp naturally embedded in Ruby Tomasz Wegrzanowski wrote: > On 7/25/06, William James wrote: > > I have to say that I come more from Objective Caml/Ruby than > from Scheme/Common Lisp, so I don't know much how Lisps > are doing different things. I want is an operator "rebind in loca > lexical environment" (global or the current lambda/defsyntax's), > more or less like Ruby's = or Python's =. Why don't you do an OCaml in Ruby instead, if you don't know the semantics of Lisp? The problem is that you're using let as a 'side-effect-operator' which it isn't. Let doesn't exist in Lisp. It's just a shortcut. This: (let ((a 1) (b 2)) (* a b)) is just a shortcut for ((lambda (a b) (* a b)) 1 2) So, you see, there's an excellent reason for let to have the semantics it have. Let is for establishing a NEW environment with different bindings. That's the main difference too what you're doing. Actually, as someone commented, your OCaml examble would look like this in lisp: (defun veclen (x y) (let ((x2 (* x x)) (y2 (* y y))) (let ((z2 (+ x2 y2))) (sqrt z2)))) which is very natural and _no_ assignment needed. The problem with your example from a lisp perspective is that it isn't obvious from your indentation or use that the let is scoped. And it can also appear anywhere, making it hard to reason about a program. With let you initialize all your bindings when the environment is established. It's just another way of doing it. Regarding setq and others,, what it does depends. If there's a local binding it will change that binding, if not, it will change the global one. > > And let means different things in different Lisps. > Scheme's let is different from Arc's. So it's not that radical. This is very much not true at all. Completely wrong, actually. > > > [about letn/let*] > I know about let*, letrec and all the Scheme magic, but I find > it very inelegant for a language to have multiple binding operators, > so I tried to do with just one :-) > > Hoho, that is _really_ wonderful. Scheme; inelegant? Because it has let* and letrec? Do you know the REASON those operators exist? No, didn't think so. -- Ola Bini (http://ola-bini.blogspot.com) JvYAML, RbYAML, JRuby and Jatha contributor System Developer, Karolinska Institutet (http://www.ki.se) OLogix Consulting (http://www.ologix.com) "Yields falsehood when quined" yields falsehood when quined.