Re: Different syntax for declarations.



Now can do:

(define-decl-macro decl-defun
(progn
(declaim
(ftype (function @lambda-signature @result-type) @param-1))
(defun &param-1 @param-1 &lambda-list &result-type &body)))

--> DECL-DEFUN

(macroexpand '(decl-defun add ((a integer) (b real)) real (+ a b)))

--> (PROGN
(DECLAIM (FTYPE (FUNCTION (INTEGER REAL) REAL) ADD))
(DEFUN ADD (A B)
(DECLARE (TYPE INTEGER A) (TYPE REAL B))
(THE REAL (PROGN (+ A B)))))

(decl-defun add ((a integer) (b real)) real (+ a b))

--> ADD

(add 1 3.0)


I'm actually more excited, than anything, by this concept of writing
the source and target template as one object. This could be used to
develop an alternate macro-writing system to augment the one we have
based on analysis with destructuring, and synthesis with backquote.
You simply express the form that you want to come out, and the
macro-writer deduces the argument syntax.

A lot of the time you don't care what the syntax is as long as it gets
all the arguments and otherwise makes sense. Maybe the machine should
choose the syntax for the macro based on hunting down the parameters in
the structure of the form.

I'm going to develop this idea further.

.