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>2017-02-20 11:16:50 -0800
commit417161dbb36323b5a6572859dedad02ca92fc65c (patch)
treee8d8476ec82339bb655dbd0c9d1f95cba90caadc /src/lisp/ao_lisp_const.lisp
parent0ee44c8e4bf5dabe6a97bf76b366c8b767c387f8 (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))
+ )
+ )
+ )
+ )
+ )
+ )