newLISP development release v.10.0.6

Started by Lutz, May 20, 2009, 11:30:05 AM

Previous topic - Next topic

Lutz

• minor feature enhancements

• bug fixes



for files and CHANGES notes see:



http://www.newlisp.org/downloads/development/">http://www.newlisp.org/downloads/development/

Kazimir Majorinc

#1
Excellent. Now my crawler tractor works without problems so we have that infinite evaluation without loop and without recursion. I think CL and Scheme have no equivalent, since their functions are not just lambda lists, but results of evaluation of lambda lists.



Thanx for fixing that. Is there any performance penalty?



I noticed similar problem here. It would be nice if that can be fixed as well.


(set 'counter 0)
(set 'f '(begin (begin (if (= (% counter 10000) 0)
                           (println "Hi for the " counter ". time. "))
                       (inc counter)
                       (push (nth 1 f) f -1)
                       (if (>= (length f) 3) (pop f 0)))))

(eval f)
(exit)
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#2
Quote ... so we have that infinite evaluation without loop and without recursion ...


Yes, your crawler tractor is a nice discovery and a fine example for self modifying code in newLISP.

 

There has been no measurable performance hit for this optimization in lambda expressions. But I don't want to do it for 'begin' where it would impact the speed of all iterating constructs where this optimization is already done on the looping level.

Jeff

#3
What prevents adding this optimization for defined functions?
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#4
Having it for lambda means its already done for defined functions too ;-).



(define (f ..) ...)

(set 'f (lambda (..) ...)

(set 'f (fn (..) ...)



its all the same.

chi

#5
Quote from: "Kazimir Majorinc"(...) I think CL and Scheme have no equivalent, since their functions are not just lambda lists, but results of evaluation of lambda lists. (...)

At least Scheme ought to have this feature. To be a Scheme, the system has to support two important features: call/cc and tail recursion optimization. For instance this (set! lop (lambda (n) (print "n: " n) (lop (+ n 1))))
(lop 1)

will run endlessly without growing stack space at around 960K. While this(set! lop! (lambda (n) (print "n: " n) (+ (lop (+ n 1)) 1)))
(lop! 1)

will slowly raise the stack space up to 1.9G while nearly killing my system :-)



But I do not know anything for CL about that ...



Ciao,

chi :-)

chi

#6
Oops, perhaps I posted too fast! Suddenly I am not sure, if I interpreted the line in the release notes
Quotelambda functions (not lambda-macro) now allow for large or infinite running bodies without stack impact
correctly!



My Scheme example will crash the newLISP interpreter due to stack size. So perhaps I did misunderstood the line above.



Could someone, please, clarify the meaning for me?



Thanks in advance and



ciao,

chi :-)

Kazimir Majorinc

#7
chi, this is about function:


(set 'f (lambda()
            (begin (println "Hi for the " (inc counter) ". time. ")
                   
                   (push (last f) f -1)
                   (if (> (length f) 3) (pop f 1)))))

(f)


This function modifies its code during evaluation, so it runs indefinitely although there is no loop or recursion. Until recently this function didn't released memory so at one point (800 000 "Hi" on my Newlisp) it crashed. Now Lutz fixed it. I wrote about it http://kazimirmajorinc.blogspot.com/2009/04/crawler-tractor.html">here and Alessandro wrote in his blog in Italian http://newlisp.wordpress.com/2009/05/04/funzione-non-ricorsiva-e-senza-loop-che-viene-eseguita-indefinitivamente/">here. (http://translate.google.com/#">Google translate for those of us who do not know Italian.)



I think it is not possible to do the same directly in Scheme or Cl, because their functions are not lists, but results of evaluation of lists so they cannot be modified "in fly". But maybe I'm wrong. Maybe it is possible using eval, I didn't tried.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Jeff

#8
Quote from: "Lutz"Having it for lambda means its already done for defined functions too ;-).



(define (f ..) ...)

(set 'f (lambda (..) ...)

(set 'f (fn (..) ...)



its all the same.


That's what I was hoping, but the wording made me wonder.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

chi

#9
Quote from: "Kazimir Majorinc"chi,  (...)

This function modifies its code during evaluation, so it runs indefinitely although there is no loop or recursion. (...) I wrote about it (...)


Hello Kazimir,



thank you very much for your explanation. Now I do understand! I think, you are right, that this is not normally possible via CL or Scheme. But OTOH both languages are not forced to compile theirs lambdas, so there may be some implementations, where this nice trick could be possible :-)



Unfortunately I did not stumble over said article of your block, as that would probably spared you the time to answer my question ...



I am at blog article #7 right now ... well done! :-D



Ciao,

chi :-)

newdep

#10
Lutz,



Is it default that the $0–$15 are not cleared befor a function is called that uses these.. Like regex?



Im running into old content (previously returned regex data)  inside $1...$15 when using regex multiple times..

(tested on Windows XP only)



Norman.
-- (define? (Cornflakes))

Lutz

#11
Your code will always know how many subexpressions you have used in your pattern, if the regular expression fails, you know the sub expressions are invalid and old.



There is normally no need to clear these and it would take much performance doing this. If you must clear them for some reason, you  can do it, system variables $0 thru $15 are the only once which are not protected.

cormullion

#12
Quote from: "newdep"Is it default that the $0–$15 are not cleared befor a function is called that uses these.. Like regex?


Yes, that's standard behaviour... ! :)



http://www.alh.net/newlisp/phpbb/viewtopic.php?t=2427">//http://www.alh.net/newlisp/phpbb/viewtopic.php?t=2427

http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1948">//http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1948

newdep

#13
Aaah yeah look.. thanks! ;-)
-- (define? (Cornflakes))