Some commands

This page contains addition description of the following commands tagbody, block, eval,

tagbody

This is an example of tagbody and go. The example is simple, it shows all instructions executed by Endymion.

[Endymion] (defun test (x)
[Endymion]  (newl xl x)
[Endymion]  (if (<= n 0) (go magne) (newl l (decr n)) (go tour)))
test
[Endymion] (traceval (let ((n 5) l) (tagbody tour (test n) magne) l))
--> (let ((n 5) l) (tagbody tour (test n) magne) l)
--> ((lambda (n l) (tagbody tour (test n) magne) l) 5 ())
--> (lambda (n l) (tagbody tour (test n) magne) l)
--> (#:system:lambda 2 (n l) (tagbody tour (test n) magne) l)
<-- (#:system:lambda 2 (n l) (tagbody tour (test n) magne) l)
<-- (#:system:lambda 2 (n l) (tagbody tour (test n) magne) l)
--> 5
<-- 5
--> ()
<-- ()
n--> 5
l--> ()
--> (tagbody tour (test n) magne)
--> (test n)
--> n
<-- 5
x--> 5
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 5
--> xl
<-- ()
<-- (5)
<-- (5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 5
--> 0
<-- 0
<-- ()
--> (setq l (cons (setq n (- n 1)) l))
--> (cons (setq n (- n 1)) l)
--> (setq n (- n 1))
--> (- n 1)
--> n
<-- 5
--> 1
<-- 1
<-- 4
<-- 4
--> l
<-- ()
<-- (4)
<-- (4)
--> (go tour)
find goto tour ok
x<-- _undef_
--> (test n)
--> n
<-- 4
x--> 4
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 4
--> xl
<-- (5)
<-- (4 5)
<-- (4 5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 4
--> 0
<-- 0
<-- ()
--> (setq l (cons (setq n (- n 1)) l))
--> (cons (setq n (- n 1)) l)
--> (setq n (- n 1))
--> (- n 1)
--> n
<-- 4
--> 1
<-- 1
<-- 3
<-- 3
--> l
<-- (4)
<-- (3 4)
<-- (3 4)
--> (go tour)
find goto tour ok
x<-- _undef_
--> (test n)
--> n
<-- 3
x--> 3
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 3
--> xl
<-- (4 5)
<-- (3 4 5)
<-- (3 4 5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 3
--> 0
<-- 0
<-- ()
--> (setq l (cons (setq n (- n 1)) l))
--> (cons (setq n (- n 1)) l)
--> (setq n (- n 1))
--> (- n 1)
--> n
<-- 3
--> 1
<-- 1
<-- 2
<-- 2
--> l
<-- (3 4)
<-- (2 3 4)
<-- (2 3 4)
--> (go tour)
find goto tour ok
x<-- _undef_
--> (test n)
--> n
<-- 2
x--> 2
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 2
--> xl
<-- (3 4 5)
<-- (2 3 4 5)
<-- (2 3 4 5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 2
--> 0
<-- 0
<-- ()
--> (setq l (cons (setq n (- n 1)) l))
--> (cons (setq n (- n 1)) l)
--> (setq n (- n 1))
--> (- n 1)
--> n
<-- 2
--> 1
<-- 1
<-- 1
<-- 1
--> l
<-- (2 3 4)
<-- (1 2 3 4)
<-- (1 2 3 4)
--> (go tour)
find goto tour ok
x<-- _undef_
--> (test n)
--> n
<-- 1
x--> 1
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 1
--> xl
<-- (2 3 4 5)
<-- (1 2 3 4 5)
<-- (1 2 3 4 5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 1
--> 0
<-- 0
<-- ()
--> (setq l (cons (setq n (- n 1)) l))
--> (cons (setq n (- n 1)) l)
--> (setq n (- n 1))
--> (- n 1)
--> n
<-- 1
--> 1
<-- 1
<-- 0
<-- 0
--> l
<-- (1 2 3 4)
<-- (0 1 2 3 4)
<-- (0 1 2 3 4)
--> (go tour)
find goto tour ok
x<-- _undef_
--> (test n)
--> n
<-- 0
x--> 0
--> (setq xl (cons x xl))
--> (cons x xl)
--> x
<-- 0
--> xl
<-- (1 2 3 4 5)
<-- (0 1 2 3 4 5)
<-- (0 1 2 3 4 5)
--> (if (<= n 0) (go magne) (setq l (cons (setq n (- n 1)) l)) (go tour))
--> (<= n 0)
--> n
<-- 0
--> 0
<-- 0
<-- true
--> (go magne)
find goto magne ok
x<-- _undef_
<-- ()
--> l
<-- (0 1 2 3 4)
l<-- _undef_
n<-- _undef_
<-- (0 1 2 3 4)
<-- (0 1 2 3 4)
(0 1 2 3 4)

block

This is an example of block and friends. The original LeLisp version used #'(lambda() (return-from here 4)). The sharp-quote mechanism constructs a function, this is a bit more complicated than a list that starts with lambda. In fact, it contains the lambda and the lexical link. This is not implemented in Endymion. On the other hand, you can use block-with-llink, this puts the lexical link into its second argument, and return-from-llink, this reads the lexical link from its second argument. Hence, instead of the lambda shown above, you should use something like (lambda () (return-from-llink here '6 4)).

[Endymion] (defun cexl (f g x)
[Endymion]    (if (= x 0)
[Endymion]    (funcall f)
[Endymion]      (let ((v ()))
[Endymion]        (block-with-llink here v
[Endymion]            (+ 5 (cexl g `(lambda () (return-from-llink here ',v 4))
[Endymion]                       (- x 1)))))))
cexl
[Endymion] (traceval (cexl () () 3))
--> (cexl () () 3)
--> ()
<-- ()
--> ()
<-- ()
--> 3
<-- 3
f--> ()
g--> ()
x--> 3
--> (if (= x 0) (funcall f) (let ((v ())) (block-with-llink here v (+ 5 (cexl
g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- 
x 1))))))
--> (= x 0)
--> x
<-- 3
--> 0
<-- 0
<-- ()
--> (let ((v ())) (block-with-llink here v (+ 5 (cexl g (list 'lambda () (
mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1)))))
--> ((lambda (v) (block-with-llink here v (+ 5 (cexl g (list 'lambda () (
mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1))))) ())
--> (lambda (v) (block-with-llink here v (+ 5 (cexl g (list 'lambda () (mcons
'return-from-llink 'here (list 'quote v) '(4))) (- x 1)))))
--> (#:system:lambda 1 (v) (block-with-llink here v (+ 5 (cexl g (list '
lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1)))))
<-- (#:system:lambda 1 (v) (block-with-llink here v (+ 5 (cexl g (list '
lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1)))))
<-- (#:system:lambda 1 (v) (block-with-llink here v (+ 5 (cexl g (list '
lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1)))))
--> ()
<-- ()
v--> ()
--> (block-with-llink here v (+ 5 (cexl g (list 'lambda () (mcons '
return-from-llink 'here (list 'quote v) '(4))) (- x 1))))
--> (+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list '
quote v) '(4))) (- x 1)))
--> 5
<-- 5
--> (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) 
'(4))) (- x 1))
--> g
<-- ()
--> (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4)))
--> 'lambda
<-- lambda
--> ()
<-- ()
--> (mcons 'return-from-llink 'here (list 'quote v) '(4))
--> 'return-from-llink
<-- return-from-llink
--> 'here
<-- here
--> (list 'quote v)
--> 'quote
<-- quote
--> v
<-- 6
<-- '6
--> '(4)
<-- (4)
<-- (return-from-llink here '6 4)
<-- (lambda () (return-from-llink here '6 4))
--> (- x 1)
--> x
<-- 3
--> 1
<-- 1
<-- 2
f--> ()
g--> (lambda () (return-from-llink here '6 4))
x--> 2
--> (if (= x 0) (funcall f) ((#:system:lambda 1 (v) (block-with-llink here v 
(+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v)
'(4))) (- x 1))))) ()))
--> (= x 0)
--> x
<-- 2
--> 0
<-- 0
<-- ()
--> ((#:system:lambda 1 (v) (block-with-llink here v (+ 5 (cexl g (list '
lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1))))) 
())
--> ()
<-- ()
v--> ()
--> (block-with-llink here v (+ 5 (cexl g (list 'lambda () (mcons '
return-from-llink 'here (list 'quote v) '(4))) (- x 1))))
--> (+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list '
quote v) '(4))) (- x 1)))
--> 5
<-- 5
--> (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) 
'(4))) (- x 1))
--> g
<-- (lambda () (return-from-llink here '6 4))
--> (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4)))
--> 'lambda
<-- lambda
--> ()
<-- ()
--> (mcons 'return-from-llink 'here (list 'quote v) '(4))
--> 'return-from-llink
<-- return-from-llink
--> 'here
<-- here
--> (list 'quote v)
--> 'quote
<-- quote
--> v
<-- 7
<-- '7
--> '(4)
<-- (4)
<-- (return-from-llink here '7 4)
<-- (lambda () (return-from-llink here '7 4))
--> (- x 1)
--> x
<-- 2
--> 1
<-- 1
<-- 1
f--> (lambda () (return-from-llink here '6 4))
g--> (lambda () (return-from-llink here '7 4))
x--> 1
--> (if (= x 0) (funcall f) ((#:system:lambda 1 (v) (block-with-llink here v 
(+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v)
'(4))) (- x 1))))) ()))
--> (= x 0)
--> x
<-- 1
--> 0
<-- 0
<-- ()
--> ((#:system:lambda 1 (v) (block-with-llink here v (+ 5 (cexl g (list '
lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4))) (- x 1))))) 
())
--> ()
<-- ()
v--> ()
--> (block-with-llink here v (+ 5 (cexl g (list 'lambda () (mcons '
return-from-llink 'here (list 'quote v) '(4))) (- x 1))))
--> (+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list '
quote v) '(4))) (- x 1)))
--> 5
<-- 5
--> (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) 
'(4))) (- x 1))
--> g
<-- (lambda () (return-from-llink here '7 4))
--> (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v) '(4)))
--> 'lambda
<-- lambda
--> ()
<-- ()
--> (mcons 'return-from-llink 'here (list 'quote v) '(4))
--> 'return-from-llink
<-- return-from-llink
--> 'here
<-- here
--> (list 'quote v)
--> 'quote
<-- quote
--> v
<-- 8
<-- '8
--> '(4)
<-- (4)
<-- (return-from-llink here '8 4)
<-- (lambda () (return-from-llink here '8 4))
--> (- x 1)
--> x
<-- 1
--> 1
<-- 1
<-- 0
f--> (lambda () (return-from-llink here '7 4))
g--> (lambda () (return-from-llink here '8 4))
x--> 0
--> (if (= x 0) (funcall f) ((#:system:lambda 1 (v) (block-with-llink here v 
(+ 5 (cexl g (list 'lambda () (mcons 'return-from-llink 'here (list 'quote v)
'(4))) (- x 1))))) ()))
--> (= x 0)
--> x
<-- 0
--> 0
<-- 0
<-- true
--> (funcall f)
--> f
<-- (lambda () (return-from-llink here '7 4))
--> (lambda () (return-from-llink here '7 4))
--> (#:system:lambda 0 () (return-from-llink here '7 4))
<-- (#:system:lambda 0 () (return-from-llink here '7 4))
<-- (#:system:lambda 0 () (return-from-llink here '7 4))
--> (return-from-llink here '7 4)
--> '7
<-- 7
--> 4
<-- 4
x<-- 1
g<-- (#:system:lambda 0 () (return-from-llink here '7 4))
f<-- (lambda () (return-from-llink here '6 4))
v<-- 7
x<-- 2
g<-- (lambda () (return-from-llink here '6 4))
f<-- ()
<-- 4
v<-- 6
<-- 4
<-- 4
x<-- 3
g<-- ()
f<-- ()
<-- 4
<-- 9
<-- 9
v<-- _undef_
<-- 9
<-- 9
<-- 9
x<-- 10
g<-- _undef_
f<-- _undef_
<-- 9
9

eval

[Endymion] (setq eval-trace true)
<-- true
true
[Endymion] (setq Bar (lambda ((a b) c (d . e) . f) (list a b c d e f)))
--> (setq Bar (lambda ((a b) c (d . e) . f) (list a b c d e f)))
--> (lambda ((a b) c (d . e) . f) (list a b c d e f))
--> (#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
<-- (#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
<-- (#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
<-- (#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
(#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
[Endymion]  (eval (cons Bar '('(1 2) 3 '(4 . 5) 6 7)))
--> (eval (cons Bar '('(1 2) 3 '(4 . 5) 6 7)))
--> (cons Bar '('(1 2) 3 '(4 . 5) 6 7))
--> Bar
<-- (#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f))
--> '('(1 2) 3 '(4 . 5) 6 7)
<-- ('(1 2) 3 '(4 . 5) 6 7)
<-- ((#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f)) '(1 2) 3 '
(4 . 5) 6 7)
--> ((#:system:lambda -4 ((a b) c (d . e) . f) (list a b c d e f)) '(1 2) 3 '
(4 . 5) 6 7)
--> '(1 2)
<-- (1 2)
--> 3
<-- 3
--> '(4 . 5)
<-- (4 . 5)
--> 6
<-- 6
--> 7
<-- 7
a--> 1
b--> 2
c--> 3
d--> 4
e--> 5
f--> (6 7)
--> (list a b c d e f)
--> a
<-- 1
--> b
<-- 2
--> c
<-- 3
--> d
<-- 4
--> e
<-- 5
--> f
<-- (6 7)
<-- (1 2 3 4 5 (6 7))
f<-- _undef_
e<-- _undef_
d<-- _undef_
c<-- _undef_
b<-- _undef_
a<-- _undef_
<-- (1 2 3 4 5 (6 7))
<-- (1 2 3 4 5 (6 7))
(1 2 3 4 5 (6 7))



back to home page © INRIA 2005 Last modified $Date: 2005/04/07 18:30:51 $