loop & recur

Pondering the philosophy behind the language
Post Reply
ClaudeM
Posts: 4
Joined: Fri Jun 21, 2019 11:46 pm

loop & recur

Post 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
Attachments
tco.zip
source code
(1.18 KiB) Downloaded 49 times

ClaudeM
Posts: 4
Joined: Fri Jun 21, 2019 11:46 pm

Re: loop & recur

Post 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

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Re: loop & recur

Post 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. :)
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Post Reply