Why is the "yet" special character in the pattern? Can this be defined as a procedure?

Recently, I began to study the Scheme by reading SICP. The first chapter deals with conditional expressions and talks about using else in the special form cond ", which, as far as I know, is defined as" what the interpreter just knows ". My question is: why else is defined as a" special form ", but not as a procedure?

If I run my mit schema interpreter and type: (else 1) , it causes an error. If I define something like (define (myelse x) x) , I can use it the same way as it is used in the cond expression, for example:

 (define (abs x) (cond ((< x 0) (- x)) (myelse x))) 

So, why else seen as something special and not defined in the schema itself?

+4
source share
1 answer

If it were a regular variable, you could do:

 (set! else #f) 

and then all cond expressions that depend on the else condition being executed will stop working.

+7
source

Source: https://habr.com/ru/post/1492430/


All Articles