Alex Shinn <alexsh...@gmail.com> writes: >> Of course, it is not hard to work around these seemingly pointless >> prohibitions, just as it would not be hard to write >> >> (if (null? xs) 0 (apply + xs)) >> >> instead of >> >> (apply + xs) >> >> but I don't understand why we should have to. What's the compelling >> argument on the other side that justifies these annoyances? > > This analogy is meaningless, but for the record > you should be using fold or reduce here.
Yes, I'm aware that using `fold' or `reduce' is more robust for large lists. You could just as easily correct anyone who uses alists in a simple example and say "for the record you should be using a balanced tree instead." Or perhaps you're advocating (reduce + 0 xs) over (apply + xs) as a matter of style. If so, I happen to agree with you, but that's not the point. The point is, (apply + xs) is a sensible thing for someone to do if xs is not huge, and it's good that Scheme treats this degenerate case properly. Similarly, if we are generating a sequence of expressions to be evaluated for effects only, then an empty sequence has a perfectly logical and obvious meaning. Thanks, Mark