[Q] Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
Stephen J. Turnbull
stephen at xemacs.org
Sat Sep 18 13:11:49 EDT 2010
Aidan Kehoe writes:
> The programmer can’t assume he or she will always be working with
> the XEmacs 21.5 byte compiler. Say, if they’re writing package
> code.
Sure, but I don't think it's the byte compiler's job to teach
programmers to hand-optimize.
> > from the answer, you wouldn't be able to determine which list
> > element was tickling the bug, but with a "(nconc (mapcar ...))"
> > form, you could, using a debugger.
>
> I don’t understand your point here.
The basic point is that in debugging the user may wish to examine the
individual lists produced by the mapcar. With the (mapcan ...)
version, you can't determine the boundaries of the lists from the
result, and the nils are of course lost entirely. So you'd need to
write a separate function to get that information, which might be
non-trivial if there was some complex process producing the list of
arguments for the mapped function.
With the (nconc (mapcar ...)) version, you can run interpreted for
debugging and see the arguments to `nconc' in a backtrace or at a
breakpoint, without changing the source.
More information about the XEmacs-Patches
mailing list