Re: Opposite of ~^ FORMAT Directive
- From: Joerg Hoehle <hoehle@xxxxxxxxxxxxxxxxxxxxx>
- Date: 30 Apr 2007 17:45:08 +0200
Kent,
Kent M Pitman <pitman@xxxxxxxxxxx> writes:
comes to mind, and it's really an ugly trick--but worth knowing, is to
use some sort of circular list thing, as in:
(mapcar #'list ;this mapcar will stop as long as x is not circular!
(cons nil (circular-list t))
x)))
Some people these recent years are extremely pedantic about strict
interpretation of the ANSI-CL (or rather the CLHS), possibly putting
more into its wording than the authors intended to.
One can derive from the entry on MAPCAR:
MAPCAR function &rest lists => result list
Exceptional situations:
Should be prepared to signal an error of type type-error if any list
is not a proper list.
that your code suggestion is not portable code.
However I've come across plenty of (historic?) Lisp code which depends
on this circular list trick wo work with MAPCAR (and other sequence or
list functions). Probably no implementation will choose to signal an
error at the risk of seeing some software library fail (or plainly
because they won't perform an extra check for circular lists) -- or
now that I've pointed at it, they'll change the Lisp implementation
because historic code could be crap ;)
Yet it other areas, these same implementations appear
"plus royaliste que le roi".
E.g. (LENGTH '(2 3 . 4)) signals an error in many implementations,
whereas the MAPCAR trick works. I would have been happy with LENGTH
counting the number of conses reachable from CDR, e.g. 2.
Do you think CL need a CIRCULAR-LIST-ARGUMENTS writeup similar to
DOTTED-LIST-ARGUMENTS?
http://www.lispworks.com/documentation/HyperSpec/Issues/iss138.htm
Regards,
Jorg Hohle
Telekom/T-Systems Technology Center
.
- Follow-Ups:
- Re: Opposite of ~^ FORMAT Directive
- From: Kent M Pitman
- Re: Opposite of ~^ FORMAT Directive
- References:
- Opposite of ~^ FORMAT Directive
- From: vy
- Re: Opposite of ~^ FORMAT Directive
- From: Kent M Pitman
- Opposite of ~^ FORMAT Directive
- Prev by Date: Springtime for AI?
- Next by Date: Re: Writing HTML parser wasn't as hard as I thought it'd be
- Previous by thread: Re: Opposite of ~^ FORMAT Directive
- Next by thread: Re: Opposite of ~^ FORMAT Directive
- Index(es):
Relevant Pages
|