[email protected] (Ludovic Courtès) writes:

> Hi,
>
> Thien-Thi Nguyen <[email protected]> writes:
>
>> At the moment, i would ask you to look at the guile-user message
>> w/ subject "(define ((f a) b) ...)".
>
> I didn’t reply on the grounds that Andy may have his views on this.  :-)

I think it just needs a bit of define-syntax.

As it happens, the definition of define-public has the required form:

(define-syntax define-public
  (syntax-rules ()
    ((_ (name . args) . body)
     (define-public name (lambda args . body)))
    ((_ name val)
     (begin
       (define name val)
       (export name)))))

and it works:

scheme@(guile-user)> (define-public ((f a) b) (* a b))
scheme@(guile-user)> (f 2)
#<program a117550 (b)>
scheme@(guile-user)> ((f 2) 3)
6

But I completely agree that we want `define' to support that too, `out
of the box'.

What is the correct way of writing something like this in boot-9.scm?

(define-syntax primitive-define define)

(define-syntax define
  (syntax-rules ()
    ((_ (name . args) . body)
     (define name (lambda args . body)))
    ((_ name val)
     (begin
       (primitive-define name val)
       (export name)))))

Regards,
      Neil


Reply via email to