1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-28 16:00:22 +02:00

elisp `labels'

* module/language/elisp/compile-tree-il.scm (compile-labels): New
  special operator.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
This commit is contained in:
BT Templeton 2011-08-08 18:50:04 -04:00
parent 0e5b7e74e4
commit 1c2f9636dc
2 changed files with 23 additions and 0 deletions

View file

@ -39,6 +39,7 @@
compile-let compile-let
compile-lexical-let compile-lexical-let
compile-flet compile-flet
compile-labels
compile-let* compile-let*
compile-lexical-let* compile-lexical-let*
compile-guile-ref compile-guile-ref
@ -637,6 +638,26 @@
(map (cut parse-flet-binding loc <>) bindings) (map (cut parse-flet-binding loc <>) bindings)
body)))) body))))
(defspecial labels (loc args)
(pmatch args
((,bindings . ,body)
(let ((names+vals (map (cut parse-flet-binding loc <>) bindings)))
(receive (decls forms) (parse-body body)
(let ((names (map car names+vals))
(vals (map cdr names+vals))
(gensyms (map (lambda (x) (gensym)) names+vals)))
(with-lexical-bindings
(fluid-ref bindings-data)
names
gensyms
(lambda ()
(make-letrec #f
loc
names
gensyms
(map compile-expr vals)
(compile-expr `(progn ,@forms)))))))))))
(defspecial let* (loc args) (defspecial let* (loc args)
(pmatch args (pmatch args
((,bindings . ,body) ((,bindings . ,body)

View file

@ -28,6 +28,7 @@
(compile-let . let) (compile-let . let)
(compile-lexical-let . lexical-let) (compile-lexical-let . lexical-let)
(compile-flet . flet) (compile-flet . flet)
(compile-labels . labels)
(compile-let* . let*) (compile-let* . let*)
(compile-lexical-let* . lexical-let*) (compile-lexical-let* . lexical-let*)
(compile-guile-ref . guile-ref) (compile-guile-ref . guile-ref)
@ -52,6 +53,7 @@
let let
lexical-let lexical-let
flet flet
labels
let* let*
lexical-let* lexical-let*
guile-ref guile-ref