On Fri, Jan 25, 2008 at 11:26:19PM -0800, [EMAIL PROTECTED] wrote:
It seems to me that "cond+else" and "if" do the same thing.
Not sure why Scheme has/needs BOTH.

e.g.

(define (find-sign x) (cond     ((< x 0) "negative")
                                (else "positive")))

(define (find-sign x) (if       (< x 0) "negative" "positive"))

Only one of 'if' or 'cond' is needed.  R5RS defines 'if' as primitive, and
that 'cond' can be defined in terms of it using macros.  It is rarely
implemented that way, though.

Yes, Scheme's goal was to eliminate some of lisp's complexity, but it still
needs to maintain a balance to be practical.

You don't need the function definition of define, either.

  (define (foo x) ...)

is the same as

  (define foo (lambda (x) ...))

but it gets tedious enough to warrant the extra complexity of the other
construct.

On the other hand, Scheme implements call-with-current-continuation which
has a pervasive impact on the complexity of the implementation, or at least
if it cares about performance.

David

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to