From: Ola Bini Date: 2006-07-28T04:12:28+09:00 Subject: Re: RLisp - Lisp naturally embedded in Ruby Tomasz Wegrzanowski wrote: > On 7/27/06, Daniel Martin wrote: >> "Tomasz Wegrzanowski" writes: >> > Can we macro around it or something, so that >> > (set-local-variable variable value) introduces a function-local >> variable >> > without increasing indentation level each time it's being done? >> > >> > I think it's reasonable to write something like that (whatever the >> names >> > of set-local-variable operator is): >> > >> > (defun veclen (x y) >> > (set-local-variable x2 (* x x)) >> > (set-local-variable y2 (* y y)) >> > (set-local-variable z2 (+ x2 y2)) >> > (sqrt z2) >> > ) >> >> Well, you can't quite do that but you can easily do something like >> this: >> >> (defun veclen (x y) >> (easy-local-progn >> (local x2 (* x x)) >> (local y2 (* y y)) >> (local z2 (+ x2 y2)) >> (sqrt z2) >> ) >> ) >> >> Or: >> >> (defun-with-local veclen (x y) >> (local x2 (* x x)) >> (local y2 (* y y)) >> (local z2 (+ x2 y2)) >> (sqrt z2) >> ) > > So, how would such a macro look like ? > You would have to do a code-walker (with all the glory such a thing brings), find all places where you have local and more or less replace them with let and let* each time you find one. -- 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.