Add function definition support

* geesh/eval.scm (eval-sh): Handle '<sh-defun>'.
This commit is contained in:
Timothy Sample 2018-11-08 22:22:23 -05:00
parent 93a5cba568
commit 3fad06a756
1 changed files with 4 additions and 0 deletions

View File

@ -65,6 +65,10 @@ environment @var{env}."
(sh:and env (exp->thunk env exp1) (exp->thunk env exp2)))
(('<sh-begin> . sub-exps)
(for-each (cut eval-sh env <>) sub-exps))
(('<sh-defun> name . sub-exps)
(let ((proc (lambda (env . args)
(eval-sh env `(<sh-begin> ,@sub-exps)))))
(define-environment-function! env name proc)))
(('<sh-exec> words ..1)
(let ((args (append-map (cut eval-word env <>) words)))
(match args