loop & recur

Started by ClaudeM, July 01, 2021, 03:41:31 PM

Previous topic - Next topic

ClaudeM

Allô,



I like newLISP and got to use it at work for some CSV processing. Thank you.



I come from Scheme and miss simple recursion. I wrote some macros to implement loop & recur (I am not a fan of Clojure). Does this agree with the newLISP way? Is the code OK? These are my first macros.



I tried putting in in the body of the message, but preview choked. I have attached it.



Merci.



--

ClaudeM

ClaudeM

#1
Allô,



There are two questions: a philosophical one and a practical one.



1) Is adding loop & recur to newLISP a deviation from the "character" of newLISP? Is iteration a preferred solution? Is trampolining used where a recursive solution makes sense?



2) The supplied macros are a proof of concept; they may be quite inefficient? There is likely room for improvement. Is trampolining more efficient?



Has this been discussed before? Searching for "recur" in the forum did not find anything.



Merci.



--

ClaudeM

newBert

#2
I really like NewLISP and yet I miss the optimised terminal recursion too. I'm interested in your macro, which I'm currently testing. It seems a bit slower than the 'trampolines' (just an impression, not verified), but it is much easier to use, and also more elegant. Obviously, an iterative loop will always be more efficient, but it can be frustrating when our reasoning is definitely conditioned by Lisp or Scheme. :)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>