guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why not support (begin), (cond), (case-lambda), etc?


From: Mark H Weaver
Subject: Re: Why not support (begin), (cond), (case-lambda), etc?
Date: Fri, 06 Jan 2012 12:11:12 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Alex Shinn <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]