rfc: array literals

Ralf Juengling <[email protected]> Fri, 12 Dec 2008 16:20:33 -0800 (PST)
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Hello,

Consider this code, which exhibits a malicious bug.

(defun test0 ()
   (for (i 0 3)
     (let ((v [0 0 0 0 0]))
       (v 0 (+ (v 0) 1))
       (printf "%f " (v 0)) ))
   (print) )

? (test0)
1 2 3 4
= ()

The desired output is "1 1 1 1". If I remember correctly,
somewhere in the documentation array literals are advertised
as a means to simulate something like "static variables" in
C. But here it does not square with the semantics of let.

In my opinion, this is behavior will be confusing to many
users and we should change it in Lush2. When compiled, v
should simply be allocated on the stack when it is not returned
(and dynamically otherwise).

Ralf

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/