Promoting my blog.

Started by Kazimir Majorinc, May 08, 2008, 08:10:26 PM

Previous topic - Next topic

itistoday

#30
Great blog Kazimir! I worked through your genlet function and modified it a bit to avoid some variable capture possibilities, as well as changing it to support both forms of 'let' (i.e: (let (i 0) .. ) vs. (let ((i 0)) .. )):


(define-macro (genlet)
(if (list? (args 0 0))
; (genlet ((var1 val1) (var2 val2)) ... )
(letex
( H1 (map (fn (x) (list (x 0) '(gensym))) (args 0))
H2 (args 0)
  H3 (cons 'begin (rest (args)))
H4 (cons 'begin (map
(fn (x) (list 'delete (list 'quote (x 0))))
(args 0)))
)
(letex H1 (first (list (let H2 H3) H4)))
)
; (genlet (var1 val1 var2 val2) ... ) => convert to other form
(letex (H1 (cons 'genlet (cons (explode (args 0) 2) (rest (args)))))
(eval H1)
)
)
)
Get your Objective newLISP groove on.

Kazimir Majorinc

#31
Thanx, itistoday.



I have noted that actually letex does different thing than I though initially. I thought that



(letex((x 1))(f x))



is equivalent to



(f 1)



while local binding of x to 1 does not exist in time of evaluation. It turned it is not true, as can be seen from this code:


(set 'x 100)
(letex ((x 1))
      (print (eval (sym "x")))

(exit)

It evaluates to - 1, not to 100.



It happens because



(letex((x 1))(f x something))



is actually



(let ((x 1))(eval (expand '(f x something) 'x))



and not



(eval (let ((x 1))(expand '(f x something) 'x))



as I thought to be. So, x=1 binding is actually alive in moment of eval. It might cause overshadowing of some outer x. That's why I have to replace all letex with "manual" combination of eval and expand.



Lutz, maybe letex should be replaced or supported with evlex?
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#32
Yes, it is the local version of 'x' which gets expanded, and the body of the 'letex' expression gets evaluated in the local scope. Like in a simple 'let', the locals shadow the outer scope.



'letex' is like a 'let' plus expansion of locals in the body before the evaluation of that body. You take out the expansion and have a normal 'let'.

Kazimir Majorinc

#33
Two new items:



* On macroexpansion.

* Crawler tractor.



http://www.instprog.com/crawler-tractor/Landwasserschlepper%20comienza%20en%201936green.png">
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

newdep

#34
Hi Kazimir,



I did not see my feedback on you blog so im posting it here..



Im getting a Stack error when using your infinite loop function push/pop.

(Crawler Tractor)



ERR: call stack overflow : pop <8060DC0>

called from user defined function f



That is a little odd i think because your function is in my eyes not

consuming memory/stack... It is though hitting the 64bit barrier, but

then the newlisp error message is wrong...



btw..nice pictures..heheh Real! Enginering..
-- (define? (Cornflakes))

Kazimir Majorinc

#35
Same for me, at



"Hi for the 790000. time."



(sys-info) suggests that number of Lisp cells - is growing all the time. It appears that pop doesn't release memory.



Yes, vehicle is great. Landwasserschlepper from 1936.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

axtens

#36
While we're on the subject of blogs, I've just made my first newLISP posting on http://codeaholic.blogspot.com/2009/04/newlisp-reverse-find.html">my own blog



Kind regards,

Bruce.

Lutz

#37
The error message is misleading and will be changed, its not the call stack but the result-stack from ORO management which never gets cleared in Kazimir's self modifying function, which never returns. Under normal circumstances 'pop' will release memory.

Kazimir Majorinc

#38
Lutz, is there a chance to make this normal circumstance? Or at least to add some command for manual memory release in that case?



One advantage of the ORO concept might be that functions know their reference, being it some symbol, like x, or expression like (L 1). Any chance for that? Sorry if I asked for that already, I forgot.



Very interesting blog, axtens. Impressive number of programming languages.



I encourage everyone to start writting blog because it really helps. Helps in what? To initiate or increase communication about topics you want to communicate.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

axtens

#39
Quote from: "Kazimir Majorinc"Very interesting blog, axtens. Impressive number of programming languages.



I encourage everyone to start writting blog because it really helps. Helps in what? To initiate or increase communication about topics you want to communicate.


Thanks for the encouragement. Yes, maintaining a weblog is good on a variety of levels, including as practice in making technical writing comprehensible.



-- Bruce.

cgs1019

#40
Quote from: "Kazimir Majorinc"Thanx, itistoday.

Lutz, maybe letex should be replaced or supported with evlex?



(eval (letex ((x 1)) '(f x)))


quoting the expr and wrapping in eval does the trick for me[/code]
-- Christopher Suter



\"The only reason for time is so that everything doesn\'t happen at once.\"

Albert Einstein

Lutz

#41
Kazimir, this is an issue with the maximum of consecutive blocks/statements in a lambda function. The same case it taken care of in all loops and many other statements which iterate in some form and regularly free memory. Introducing this mechanism to lambda and lambda-macro functions would cost too much overhead.



Keeping lambda and lambda-macro overhead at an absolute minimum is important for Lisp, as good Lisp programming style favors smaller functions. At the moment a cleanup only occurs upon leaving the function. For normal programming purpose ~4000 statements-blocks in one function are more than enough.

Kazimir Majorinc

#42
Quote from: "Lutz"Keeping lambda and lambda-macro overhead at an absolute minimum is important for Lisp, as good Lisp programming style favors smaller functions. At the moment a cleanup only occurs upon leaving the function.


OK, then maybe in future when speed will be even less critical than today.


Quote from: "cgs1019"
(eval (letex ((x 1)) '(f x)))


Yes, you're right it is simpler than


(eval (let ((x 1))
             (expand '(f x) 'x)))
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#43
but this:


(eval (letex ((x 1)) '(f x)))

is the same as this:


(letex ((x 1)) (f x))

'letex' does evaluate after expanding

itistoday

#44
Quote from: "Lutz"'letex' does evaluate after expanding


That reminds me of something I wanted to ask you.  In the 'genlet' code that I gave above, why do I have to have the extra 'eval' here:


     (letex (H1 (cons 'genlet (cons (explode (args 0) 2) (rest (args)))))
         (eval H1)
      )


But not here:


     (letex
         (    H1 (map (fn (x) (list (x 0) '(gensym))) (args 0))
            H2 (args 0)
              H3 (cons 'begin (rest (args)))
            H4 (cons 'begin   (map
                           (fn (x) (list 'delete (list 'quote (x 0))))
                        (args 0)))
         )
         (letex H1 (first (list (let H2 H3) H4)))
      )
Get your Objective newLISP groove on.