Page 1 of 1

loop & recur

Posted: Thu Jul 01, 2021 10:41 pm
by 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

Re: loop & recur

Posted: Sat Jul 03, 2021 5:11 pm
by ClaudeM
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

Re: loop & recur

Posted: Tue Jul 06, 2021 1:30 pm
by newBert
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. :)