diff --git a/module/language/elisp/README b/module/language/elisp/README index 931de7f34..2c23a947f 100644 --- a/module/language/elisp/README +++ b/module/language/elisp/README @@ -38,7 +38,7 @@ Compiler options implemented: for void value on access either completely or for some symbols Extensions over original elisp: - * guile-ref + * guile-ref, guile-primitive * flet and flet* * lexical-let and lexical-let* @@ -46,15 +46,16 @@ Extensions over original elisp: Details to the implemented extensions ===================================== -guile-ref: ----------- +guile-ref and guile-primitive: +------------------------------ (guile-ref module sym) is a new special construct to access symbols from the -Guile-world (for instance, Guile primitives directly but it also allows to -set some variables in other modules than the elisp runtime ones). +Guile-world. Actually, (guile-ref module sym) is the same as (@ module sym) +would be in Scheme. Both module and sym must be statically given and are not +evaluated. -Actually, (guile-ref module sym) is the same as (@ module sym) would be in -Scheme. Both module and sym must be statically given and are not evaluated. +(guile-primitive sym) does the same to access a Guile primitive directly, which +is slightly faster where applicable. flet and flet*: --------------- diff --git a/module/language/elisp/compile-tree-il.scm b/module/language/elisp/compile-tree-il.scm index 30ca24dea..6a81d3025 100644 --- a/module/language/elisp/compile-tree-il.scm +++ b/module/language/elisp/compile-tree-il.scm @@ -701,12 +701,17 @@ (generate-let* loc function-slot bindings body)) ; guile-ref allows building TreeIL's module references from within - ; elisp as a way to access data (and primitives, for instance) within + ; elisp as a way to access data within ; the Guile universe. The module and symbol referenced are static values, ; just like (@ module symbol) does! ((guile-ref ,module ,sym) (guard (and (list? module) (symbol? sym))) (make-module-ref loc module sym #t)) + ; guile-primitive allows to create primitive references, which are still + ; a little faster. + ((guile-primitive ,sym) (guard (symbol? sym)) + (make-primitive-ref loc sym)) + ; A while construct is transformed into a tail-recursive loop like this: ; (letrec ((iterate (lambda () ; (if condition diff --git a/test-suite/tests/elisp-compiler.test b/test-suite/tests/elisp-compiler.test index 7b879996c..5f154d2e6 100644 --- a/test-suite/tests/elisp-compiler.test +++ b/test-suite/tests/elisp-compiler.test @@ -304,13 +304,13 @@ (lambda () (setq cnt (1+ cnt))))) (setq c1 (make-counter) c2 (make-counter)) - (= ((guile-ref (guile) apply) c1 '()) 1) - (= ((guile-ref (guile) apply) c1 '()) 2) - (= ((guile-ref (guile) apply) c1 '()) 3) - (= ((guile-ref (guile) apply) c2 '()) 1) - (= ((guile-ref (guile) apply) c2 '()) 2) - (= ((guile-ref (guile) apply) c1 '()) 4) - (= ((guile-ref (guile) apply) c2 '()) 3)))) + (= ((guile-primitive apply) c1 '()) 1) + (= ((guile-primitive apply) c1 '()) 2) + (= ((guile-primitive apply) c1 '()) 3) + (= ((guile-primitive apply) c2 '()) 1) + (= ((guile-primitive apply) c2 '()) 2) + (= ((guile-primitive apply) c1 '()) 4) + (= ((guile-primitive apply) c2 '()) 3)))) (with-test-prefix/compile "defconst and defvar"