Re: Multivalue tail recursion?
- From: David Golden <david.golden@xxxxxxxxxxxxx>
- Date: Fri, 07 Sep 2007 19:14:10 +0100
David Trudgett wrote:
Is there any advantage to using ITERATE (and/or SERIES) instead of
LOOP?
Iterate:
Well, iterate just plain looks nicer/lispier than loop (subjective), and
you might therefore find it easier to read. It also has
pseudo-generators and a defined means of extension (e.g. iterating
over db query results or whatever).
http://common-lisp.net/project/iterate/doc/Differences-Between-Iterate-and-Loop.html
The iterate manual has comparisons:
http://common-lisp.net/project/iterate/doc/Don_0027t-Loop-Iterate.html
Series:
Waters' Series, dating originally from the 1980s, is a different way of
writing code, centered around series, perhaps best considered an early
instance of the lazy/infinite data structure idea later vastly
elaborated in Haskell. Iterate _looks_ like a traditional (but
powerful) imperative looping construct, just like loop itself, whereas
series code looks functional. You might consider that an advantage:
"In particular, algorithms that are expressed as compositions of
functions operating on series/vectors/streams of data elements are much
easier to understand and modify than equivalent algorithms expressed as
loops. Unfortunately, many programmers hesitate to use series
expressions, because they are typically implemented very inefficiently.
A Common Lisp macro package (OSS) has been implemented which supports a
restricted class of series expressions, obviously synchronizable series
expressions, which can be evaluated very efficiently by automatically
converting them into loops"
- Richard C. Waters, AIM-1082, 1989, MIT.
http://series.sourceforge.net/ - beware, some annoying dead links
coupled with general sourceforge braindamage. Who is maintaining
series now? Any chance of it moving officially to common-lisp.net ?
I know the asdf-packaging project is the least painful way to install
series nowadays: http://common-lisp.net/project/asdf-packaging/
Some 'problems' of Haskell are shared by Series e.g. your code might
suddenly become much less efficient through a very minor-looking
change, and your code might seem a little too concise and hifalutin'
for some people (if they won't or can't learn series themselves
of course).
.
- Follow-Ups:
- Re: Multivalue tail recursion?
- From: David Trudgett
- Re: Multivalue tail recursion?
- References:
- Multivalue tail recursion?
- From: Erik R.
- Re: Multivalue tail recursion?
- From: Frode Vatvedt Fjeld
- Re: Multivalue tail recursion?
- From: Erik R.
- Re: Multivalue tail recursion?
- From: Mark H.
- Re: Multivalue tail recursion?
- From: David Trudgett
- Multivalue tail recursion?
- Prev by Date: Re: array element-type nil
- Next by Date: Re: (funcall #'or my-list)
- Previous by thread: Re: Multivalue tail recursion?
- Next by thread: Re: Multivalue tail recursion?
- Index(es):
Relevant Pages
|