Explanation of the circuit (construction)
it
(define a (lambda() (cons a #f)))
defines a procedure that a
, when called, returns a pair
(<the procedure a> . #f)
i.e. whose car
is the procedure itself and whose cdr
- #f
.
In other words, the evaluation result
(a)
is the result of calling a procedure a
with no arguments, which, as defined a
above,
(<the procedure a> . #f)
Hence,
(car (a))
is <the procedure a>
(because it means "call car
with the result of the evaluation (a)
")
When you add another pair of parentheses
((car (a)))
you call this procedure, which - since it is a procedure a
- returns the same result as (a)
,
(<the procedure a> . #f)
source to share
define
from the top level defines a global variable a
.
(lambda() (cons a #f)
When called, an anonymous procedure makes a pair of evaluating a
and #f
.
When you rate a
, you get the procedure. On my system, you get #<procedure:a>
.
When you rate (a)
, you receive (#<procedure:a> . #f)
. Now the way procedures are displayed is highly implementation dependent. There are no standards, but many will use a convention with a name a
, but don't count on it.
Since a
you can also get as the car
result of a call a
, you can ((car (a)))
and get the same thing as (a)
. This is because (eq? a (car (a)))
#t
.
source to share