On Nov 5, 5:45 pm, time <
timreve...@gmail.com> wrote:
> What is the rationale for returning the identity for expressions such as (*) and (+)?
Well, if you interpret (apply + some-list) and (apply * some-other-
list) as left-folds, then a starting point is needed, something to
begin accumulating from. The identity is the only value that works
correctly, so it's what gets returned when the list being folded over
has length 0. Nobody would write (+) or (*) explicitly, but having
them return the identity is the Right Thing nevertheless.
The same argument applies when expanding macros: in a degenerate case,
a macro may expand to (+) or (*), and it's usually not appropriate to
raise an exception.