mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
Added guile-primitive construct for references to primitives from Elisp.
* module/language/elisp/README: Document it. * module/language/elisp/compile-tree-il.scm: Implement guile-primitive. * test-suite/tests/elisp-compiler.test: Switched a usage of guile-ref to the now available guile-primitive.
This commit is contained in:
parent
c2c7c27755
commit
c61ec8e29e
3 changed files with 21 additions and 15 deletions
|
@ -38,7 +38,7 @@ Compiler options implemented:
|
||||||
for void value on access either completely or for some symbols
|
for void value on access either completely or for some symbols
|
||||||
|
|
||||||
Extensions over original elisp:
|
Extensions over original elisp:
|
||||||
* guile-ref
|
* guile-ref, guile-primitive
|
||||||
* flet and flet*
|
* flet and flet*
|
||||||
* lexical-let and lexical-let*
|
* lexical-let and lexical-let*
|
||||||
|
|
||||||
|
@ -46,15 +46,16 @@ Extensions over original elisp:
|
||||||
Details to the implemented extensions
|
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-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
|
Guile-world. Actually, (guile-ref module sym) is the same as (@ module sym)
|
||||||
set some variables in other modules than the elisp runtime ones).
|
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
|
(guile-primitive sym) does the same to access a Guile primitive directly, which
|
||||||
Scheme. Both module and sym must be statically given and are not evaluated.
|
is slightly faster where applicable.
|
||||||
|
|
||||||
flet and flet*:
|
flet and flet*:
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -701,12 +701,17 @@
|
||||||
(generate-let* loc function-slot bindings body))
|
(generate-let* loc function-slot bindings body))
|
||||||
|
|
||||||
; guile-ref allows building TreeIL's module references from within
|
; 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,
|
; the Guile universe. The module and symbol referenced are static values,
|
||||||
; just like (@ module symbol) does!
|
; just like (@ module symbol) does!
|
||||||
((guile-ref ,module ,sym) (guard (and (list? module) (symbol? sym)))
|
((guile-ref ,module ,sym) (guard (and (list? module) (symbol? sym)))
|
||||||
(make-module-ref loc module sym #t))
|
(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:
|
; A while construct is transformed into a tail-recursive loop like this:
|
||||||
; (letrec ((iterate (lambda ()
|
; (letrec ((iterate (lambda ()
|
||||||
; (if condition
|
; (if condition
|
||||||
|
|
|
@ -304,13 +304,13 @@
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setq cnt (1+ cnt)))))
|
(setq cnt (1+ cnt)))))
|
||||||
(setq c1 (make-counter) c2 (make-counter))
|
(setq c1 (make-counter) c2 (make-counter))
|
||||||
(= ((guile-ref (guile) apply) c1 '()) 1)
|
(= ((guile-primitive apply) c1 '()) 1)
|
||||||
(= ((guile-ref (guile) apply) c1 '()) 2)
|
(= ((guile-primitive apply) c1 '()) 2)
|
||||||
(= ((guile-ref (guile) apply) c1 '()) 3)
|
(= ((guile-primitive apply) c1 '()) 3)
|
||||||
(= ((guile-ref (guile) apply) c2 '()) 1)
|
(= ((guile-primitive apply) c2 '()) 1)
|
||||||
(= ((guile-ref (guile) apply) c2 '()) 2)
|
(= ((guile-primitive apply) c2 '()) 2)
|
||||||
(= ((guile-ref (guile) apply) c1 '()) 4)
|
(= ((guile-primitive apply) c1 '()) 4)
|
||||||
(= ((guile-ref (guile) apply) c2 '()) 3))))
|
(= ((guile-primitive apply) c2 '()) 3))))
|
||||||
|
|
||||||
(with-test-prefix/compile "defconst and defvar"
|
(with-test-prefix/compile "defconst and defvar"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue