1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +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:
Daniel Kraft 2009-07-29 14:25:33 +02:00
parent c2c7c27755
commit c61ec8e29e
3 changed files with 21 additions and 15 deletions

View file

@ -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*:
---------------

View file

@ -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

View file

@ -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"