home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!chx400!sicsun!disuns2!disuns2.epfl.ch!simon
- From: simon@lia.di.epfl.ch (Simon Leinen)
- Newsgroups: comp.lang.lisp
- Subject: Re: Advice on recursion?
- Message-ID: <SIMON.92Jul24122911@liasg1.epfl.ch>
- Date: 24 Jul 92 10:29:11 GMT
- References: <1992Jul23.192749.129@cerberus.ulaval.ca>
- Sender: news@disuns2.epfl.ch
- Organization: DI-LIA -- Ecole Polytechnique Federale de Lausanne
- Lines: 27
- Nntp-Posting-Host: liasg1.epfl.ch
- In-reply-to: vachon@chicoutimi.gel.ulaval.ca's message of 23 Jul 92 19:27:49 GMT
- X-Md4-Signature: b93cb3623b02d0860da2c86c88916b7e
-
- In article <1992Jul23.192749.129@cerberus.ulaval.ca>
- vachon@chicoutimi.gel.ulaval.ca (Pierre Vachon) writes:
-
- Are there disadvantages to using 'labels' like this:
-
- (defun foo (arg)
- (let ((...))
-
- (labels ((recursive (arg1 arg2)
- (body)))
- (recursive 'foo 'bar))))
-
- This is exactly what I use most often. The main drawback I see is
- that you typically cannot trace the internal function if it
- misbehaves. Maybe some Lisps have an extension that permits (TRACE
- (LABELS FOO RECURSIVE)) or something, but I don't know any.
-
- Decent Lisp compilers of course optimize a tail recursion to a loop.
- Good compilers also integrate the internal function into the caller,
- in which case the LABELS version is always as efficient as an explicit
- loop construct (at least Lucid and CMU CL can claim this, I believe).
-
- So in the cases where the recursive version seems more natural (which
- depends a lot on the observer), there is no reason to sacrifice
- clarity for speed anymore, if you assume a state-of-the-art compiler.
- --
- Simon.
-