summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_const.lisp
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-09 16:22:43 -0800
committerKeith Packard <keithp@keithp.com>2016-11-17 22:18:39 -0800
commita3535e28a74055c3b303dbb4111cb3d38c2817e2 (patch)
treeedeb6a0e0d79f4adfa50c34fd7c5dcb44bcd7477 /src/lisp/ao_lisp_const.lisp
parente503e46f5e9ca57b7a7d976b2ee02a3d7812bc92 (diff)
altos/lisp: Clean up OS integration bits, add defun
Provide an abstraction for the OS interface so that it can build more cleanly on Linux and AltOS. Add defun macro. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_const.lisp')
-rw-r--r--src/lisp/ao_lisp_const.lisp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp
index 621fefc4..08a511d9 100644
--- a/src/lisp/ao_lisp_const.lisp
+++ b/src/lisp/ao_lisp_const.lisp
@@ -14,9 +14,13 @@
(setq 1+ (lambda (x) (+ x 1)))
(setq 1- (lambda (x) (- x 1)))
- ; define a variable without returning the value
+ ;
+ ; Define a variable without returning the value
+ ; Useful when defining functions to avoid
+ ; having lots of output generated
+ ;
-(set 'def (macro (def-param)
+(setq def (macro (def-param)
(list
'progn
(list
@@ -127,3 +131,30 @@
)
)
)
+
+ ;
+ ; A slightly more convenient form
+ ; for defining lambdas.
+ ;
+ ; (defun <name> (<params>) s-exprs)
+ ;
+
+(def defun (macro (defun-param)
+ (let ((name (car defun-param))
+ (args (cadr defun-param))
+ (exprs (cdr (cdr defun-param))))
+ (list
+ def
+ name
+ (list
+ 'lambda
+ args
+ (cond ((cdr exprs)
+ (cons progn exprs))
+ ((car exprs))
+ )
+ )
+ )
+ )
+ )
+ )