[Q] Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form.
kehoea at parhasard.net
Sat Sep 18 12:23:47 EDT 2010
Ar an seachtú lá déag de mí Méan Fómhair, scríobh Stephen J. Turnbull:
> Aidan Kehoe writes:
> > 2010-09-16 Aidan Kehoe <kehoea at parhasard.net>
> > * byte-optimize.el (byte-optimize-apply): Transform (apply
> > 'nconc (mapcar ...)) to (mapcan ...); warn about use of the first
> > idiom.
> Why a warning here? I think that #'mapcan should be considered an
> implementation detail that the programmer really ought not to need to
> worry about, since you're always applying the optimization anyway.
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.
> It's possible that the programmer might have some reason to use the
> "(nconc (mapcar ...))" form. For example, in
> (defun vowel-p (symbol) (member 'vowel (get symbol 'character-properties)))
> (put 'a 'vowel-p (cons 'vowel (get 'a 'character-properties)))
> (put 'c 'vowel-p (cons 'vowel (get 'c 'character-properties)))
> (mapcan #'vowel-p '(a b c d))
> 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.
> I would consider a "debug-level" or "info" message that the programmer
> requests by setting log-level or something reasonable, though.
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
-- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research
More information about the XEmacs-Patches