I started learning Scheme recently by reading SICP. In the opening chapter, it goes over conditionals and it talks about using else
within the cond
"special form" - which to my understanding is defined as "something the interpreter "just knows about". My question, is why is else
defined as a "special form" and not as a procedure?
If I fire up my mit-scheme interpreter, and type: (else 1)
it raises an error. If I define something like (define (myelse x) x)
, I can use it in the same way it is used within the cond
expression like:
(define (abs x)
(cond ((< x 0) (- x))
(myelse x)))
So why is else
treated as something special, and not defined in scheme itself?
If it were an ordinary variable, you could do:
(set! else #f)
and then all the cond
expressions that depend on the else
clause being executed would stop working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With