From a8e8f0a1e3f9a08a1a965408fcbb5288b3fba7ff Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 6 Jan 2018 09:29:11 +0100 Subject: [PATCH] mes: un-defmacro optargs. WIP --- module/mes/optargs.mes | 3 --- module/mes/optargs.scm | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/module/mes/optargs.mes b/module/mes/optargs.mes index 94b0c39b..034719d9 100644 --- a/module/mes/optargs.mes +++ b/module/mes/optargs.mes @@ -26,9 +26,6 @@ (mes-use-module (mes scm)) -(define-macro (defmacro name args . body) - `(define-macro ,(cons name args) ,@body)) - (define-macro (set-procedure-property! proc key value) proc) diff --git a/module/mes/optargs.scm b/module/mes/optargs.scm index 943e21fa..8a873fe0 100644 --- a/module/mes/optargs.scm +++ b/module/mes/optargs.scm @@ -85,14 +85,12 @@ ;; bound to whatever may have been left of rest-arg. ;; -(defmacro let-optional (REST-ARG BINDINGS . BODY) +(define-macro (let-optional REST-ARG BINDINGS . BODY) (let-optional-template REST-ARG BINDINGS BODY 'let)) -(defmacro let-optional* (REST-ARG BINDINGS . BODY) +(define-macro (let-optional* REST-ARG BINDINGS . BODY) (let-optional-template REST-ARG BINDINGS BODY 'let*)) - - ;; let-keywords rest-arg allow-other-keys? (binding ...) . body ;; let-keywords* rest-arg allow-other-keys? (binding ...) . body ;; macros used to bind keyword arguments @@ -108,10 +106,10 @@ ;; -(defmacro let-keywords (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) +(define-macro (let-keywords REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let)) -(defmacro let-keywords* (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) +(define-macro (let-keywords* REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let*)) @@ -233,7 +231,7 @@ ;; Lisp dialects. -(defmacro lambda* (ARGLIST . BODY) +(define-macro (lambda* ARGLIST . BODY) (parse-arglist ARGLIST (lambda (non-optional-args optionals keys aok? rest-arg) @@ -378,10 +376,10 @@ ;; Of course, define*[-public] also supports #:rest and #:allow-other-keys ;; in the same way as lambda*. -(defmacro define* (ARGLIST . BODY) +(define-macro (define* ARGLIST . BODY) (define*-guts 'define ARGLIST BODY)) -(defmacro define*-public (ARGLIST . BODY) +(define-macro (define*-public ARGLIST . BODY) (define*-guts 'define-public ARGLIST BODY)) ;; The guts of define* and define*-public. @@ -412,13 +410,13 @@ ;; semantics. Here is an example of a macro with an optional argument: ;; (defmacro* transmorgify (a #:optional b) -(defmacro defmacro* (NAME ARGLIST . BODY) - `(define-macro ,NAME #f (lambda* ,ARGLIST ,@BODY))) +(define-macro (define-macro* NAME+ARGLIST . BODY) + `(define-macro ,(car NAME+ARGLIST) #f (lambda* ,(cdr NAME+ARGLIST) ,@BODY))) -(defmacro defmacro*-public (NAME ARGLIST . BODY) +(define-macro (define-macro*-public NAME+ARGLIST . BODY) `(begin - (defmacro* ,NAME ,ARGLIST ,@BODY) - (export-syntax ,NAME))) + (define-macro* ,NAME+ARGLIST ,@BODY) + (export-syntax ,(car NAME+ARGLIST)))) ;;; Support for optional & keyword args with the interpreter. (define *uninitialized* (list 'uninitialized))