Path: csiph.com!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 10 Aug 2024 20:23:05 +0000 From: steve g Newsgroups: gnu.emacs.help Subject: Re: TCO with named-let via macros References: <8734oi5ksx.fsf@axel-reichert.de> Date: Sat, 10 Aug 2024 16:22:54 -0400 Message-ID: <87ed6wjffl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:xwm6CJjk4ggK4ZizMSidyUCapIU= MIME-Version: 1.0 Content-Type: text/plain Lines: 27 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-qv2U1FD8+ybalUfcCmDFAM395QpIrAS1weB0VsUzeBqCOJVFlWDHH1s1wu58AX0f0WTRMjPzTBG2k3x!KVsUDsYcAwmSWx/mXl4EFo6UEBePvn8UVghN6xolR3AW+HM= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: csiph.com gnu.emacs.help:60991 Richard Smith writes: > Axel - I know that elisp doesn't optimise if an expressed recursive > function is tail-recursive. actually the byte-compiler does do tail recursive optimizations. > A practical work-around is an alterative approach using the looping > built-in's like "dotimes" (?) - where a recursive approach would have > minimalistic beauty. > Regards, Rich S check the elisp manual. it shows how to implement true tail recursion in emacs. (defun elisp-sum (args) (elisp-sum-aux args 0)) (defun elisp-sum-aux (args res) (if (null args) res (elisp-sum-aux (cdr args) (+ (car args) res)))) you can byte compile it. very simple.