Added guile-primitive construct for references to primitives from Elisp.
authorDaniel Kraft <d@domob.eu>
Wed, 29 Jul 2009 12:25:33 +0000 (14:25 +0200)
committerDaniel Kraft <d@domob.eu>
Wed, 29 Jul 2009 12:25:33 +0000 (14:25 +0200)
* 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.

module/language/elisp/README
module/language/elisp/compile-tree-il.scm
test-suite/tests/elisp-compiler.test

index 931de7f..2c23a94 100644 (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*:
 ---------------
index 30ca24d..6a81d30 100644 (file)
      (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
index 7b87999..5f154d2 100644 (file)
              (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"