From: Daniel Kraft <d@domob.eu>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Emacs Lisp, macros
Date: Tue, 14 Jul 2009 21:48:09 +0200 [thread overview]
Message-ID: <4A5CE0F9.4080904@domob.eu> (raw)
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
next reply other threads:[~2009-07-14 19:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-14 19:48 Daniel Kraft [this message]
2009-07-14 22:15 ` Emacs Lisp, macros 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A5CE0F9.4080904@domob.eu \
--to=d@domob.eu \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).