Download implementation manual - MINES Saint
Transcript
2.4. THE EVALUATION PROCESS
21
? (set! toto 7)
-> ({toto} [SET] 7)
=> 7
• lambda construct
Scheme form
Internal representation
(lambda V E) (V (begin E) [LAMBDA])
The notation [LAMBDA] represents the constant BCLAMBDA. The notation V represents a single identifier, or a list of identifiers. The notation E represents a single expression or a list of
expressions. Note that no «compilation» of the inner expression is done at that time ; compilation
occurs when the [LAMBDA] opcode is executed.
? (lambda (x) (+ x 3))
-> ((x) (begin (+ x 3)) [LAMBDA])
=> #<LAMBDA ((x) . #<ENV:1270:76>) ([F2] {+} x 3)>
• delay construct
Scheme form
(delay E)
Internal representation
([DELAY] (() (begin E) [LAMBDA]))
The notation [LAMBDA] represents the constant BCLAMBDA. The notation [DELAY] represents the constant BCDELAY. Note that no «compilation» of the inner expression is done at that
time ; compilation occurs when the [DELAY] opcode is executed.
? (delay (+ 2 3))
-> ([DELAY] (() (begin (+ 2 3)) [LAMBDA]))
;=> #<delay:1255>
• let construct
The following tables show some examples of the let construct. The first row corresponds to a
Scheme expression, the second to the internal representation of this expression.
A let construct with no local variable :
(let () E)
((C) [LET])
This let construct has a single local variable :
(let ((L1 E1 )) E)
((C L1 [ADDENV] C1 ) [LET])