Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun normal-return (v) (1+ v))
- (disassemble 'normal-return)
- ;; =>
- ;; 0 dup
- ;; 1 add1
- ;; 2 return
- (defun block-return (v)
- (cl-block 'top
- (cl-return-from 'top v)))
- (disassemble 'block-return)
- ;; =>
- ;; 0 constant --cl-block-\(quote\ top\)--
- ;; 1 pushcatch 1
- ;; 4 constant throw
- ;; 5 constant --cl-block-\(quote\ top\)--
- ;; 6 stack-ref 2
- ;; 7 call 2
- ;; 8 pophandler
- ;; 9:1 return
- (defun other-cl-return (v) (cl-return v))
- ;; =>
- ;; ... same bytecode as in `block-return'.
- (defun ret-in-while (v)
- (dotimes (i 10)
- (when (= v 20)
- (cl-return "return-1")))
- "return-2")
- (disassemble 'ret-in-while)
- ;; =>
- ;; 0 constant 10
- ;; 1 constant 0
- ;; 2:1 dup
- ;; 3 stack-ref 2
- ;; 4 lss
- ;; 5 goto-if-nil 3
- ;; 8 dup
- ;; 9 stack-ref 3
- ;; 10 constant 20
- ;; 11 eqlsign
- ;; 12 goto-if-nil 2
- ;; 15 constant throw
- ;; 16 constant --cl-block-nil--
- ;; 17 constant "return-1"
- ;; 18 call 2
- ;; 19 discard
- ;; 20:2 discard
- ;; 21 dup
- ;; 22 add1
- ;; 23 stack-set 1
- ;; 25 goto 1
- ;; 28:3 discardN 2
- ;; 30 constant "return-2"
- ;; 31 return
Advertisement
Add Comment
Please, Sign In to add comment