$native not working?
thinkyfish opened this issue · 4 comments
I've been trying to get random-integer (srfi 27) working from shen, and I cant get $native to work.
Here is a simple reproduction.
% chibi-scheme -h 500M
(define (test x) (+ x 5))
(test 5)
10
(import (shen))
(shen.shen)
Shen 2010, copyright (C) 2010 Mark Tarver
released under the Shen license
www.shenlanguage.org, version 16
running under Scheme, implementation: chibi-scheme
port 0.9 ported by Bruno Deferrari
(0-) ($native (test 5))
undefined variable: (test)
Hi @thinkyfish. Interaction with chibi-scheme is in the process of changing and not working properly right now. But if you want to make anything available inside the Shen environment you can do so by editing shen.sld
, importing a function from your module and wrapping it in a defun (necessary for the compiler to know the arity of the function which is needed for partial applications):
(define-library (shen)
(import
; ... <snip> ...
(prefix (scheme eval) $$)
(prefix (srfi 69) $$)
(prefix (srfi 27) $$) ;; Added this line
(prefix (only (chibi) current-environment import) $$))
(export shen.shen)
; ... <snip> ...
(begin
(defun random-integer (N) ($$random-integer N)) ;; added this line
(cd ".")))
; end of file
Hope this helps.
Thanks!!! Worked like a charm!
Great :)
After 0.10 is released Scheme functions will be accessible inside the Shen environment by using the scm.
prefix.
@thinkyfish you can now use scm.import-from-module
to load Scheme modules without the need to edit shen.sld
:
https://github.com/tizoc/chibi-shen#importing-bindings-from-scheme-modules