Hi Andy and all,
yesterday and today I implemented lambda expressions and
defvar/defconst/defun for elisp as well as found a (hopefully good)
solution to automatically create fluids not yet present on reference.
With these additions and some basic built-ins (mainly arithmetic/numbers
so far, but trivial to extend), I think elisp is already quite usable as
a language for simple tasks. I just pushed the elisp branch with my
additions.
For instance, this simple code works in guile's elisp language:
; Check if p is prime, but start looking for divisors at from if
; present. It seems that recursion using anonymous functions is
; not that nicely to do in elisp as in scheme (at least not before
; defining funcall/apply), so this is done using while.
(defun primep (p &optional from)
(let ((i (if from from 2)))
(while (and (/= (% p i) 0) (<= (* i i) p))
(setq i (1+ i)))
(/= (% p i) 0)))
(primep 1283939) -> #t
(primep 1283937) -> #f
(primep 1283937 1000) -> #t
While of course the #f should be %nil, this is simply because I use #f
at the moment for nil (but that will be redefined once the falsity of
%nil is corrected).
Besides some "important" built-ins like makunbound, boundp, set,
funcall, apply, fset and others, I think the next big thing to work on
will be macro support (for a more extensive list of implemented things
and stuff still missing see module/language/elisp/README) as well as a
real testsuite.
For macros (and also for funcall/apply, which ought to be able to
execute functions in form of an uncompiled list like '(lambda (a b) (+ a
b))) I will probably need some means of compiling and executing a
certain piece of code 'by hand' from within compilation. It seems that
I can do something along
((compile <my code here> #:from 'elisp) arguments to compiled code)
to do this; or is there some other way to do this that would be better
for this situation?
Regarding the test-suite: It seems to me there's no 'very extensive'
and 'complete' single test-suite for guile at the moment, but I might be
mistaken. So maybe I should create testsuite/elisp and a
run-elisp-tests.scm like the one for vm which loads/compiles/runs and
all that the individual tests? Or is there some existing framework I
can plug my tests into?
Good night!
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri