unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Emacs Lisp, macros
@ 2009-07-14 19:48 Daniel Kraft
  2009-07-14 22:15 ` Ludovic Courtès
  2009-07-23 22:09 ` Andy Wingo
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Kraft @ 2009-07-14 19:48 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-24  7:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 19:48 Emacs Lisp, macros Daniel Kraft
2009-07-14 22:15 ` Ludovic Courtès
2009-07-15  8:36   ` Daniel Kraft
2009-07-23 22:14     ` Andy Wingo
2009-07-24  7:00       ` Daniel Kraft
2009-07-23 22:09 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).