lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New hosting for Urs Liska's Scheme WIP book


From: Jean Abou Samra
Subject: Re: New hosting for Urs Liska's Scheme WIP book
Date: Fri, 4 Nov 2022 15:42:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

Le 04/11/2022 à 15:20, David Kastrup a écrit :
Ok, I'll give the doc text another try, but the documentation block in
the manual starts with:

     Macro: make-relative …

which is missing the input arguments from

     (define-syntax-rule-public (make-relative (variables ...) reference music)

Is that fixable in some manner?  If necessary, creating a
LilyPond-specific version of define-syntax-rule-public ?



Guile doesn't give us the arguments from the header of a
define-syntax-rule, at least not in the same way it does
for procedures.

$ ~/lilies/2.23.80/bin/lilypond scheme-sandbox
GNU LilyPond 2.23.80 (running Guile 2.2)
[...]
scheme@(#{ g101}#)> (use-modules (ice-9 session))
scheme@(#{ g101}#)> (procedure-arguments (macro-transformer (module-ref (current-module) 'make-relative))) $1 = ((required x) (optional) (keyword) (allow-other-keys? . #f) (rest . #f))


It says there is a single argument "x" to the syntax transformer,
which is indeed true considering that it is a procedure taking
a single syntax object. Essentially,

(define-syntax-rule (name <args>)
  <body>)

expands to

(define-syntax name
  (lambda (x)
    (syntax-case x ()
      ((_ <args>)
       (syntax <body>)))))

The lambda ends up having "x" as its only argument. I don't believe
Guile retains the info of what <args> is as some sort of metadata on
the lambda.

Of course, you could change the definition of
define-syntax-rule-public in lily.scm from

(define-syntax-rule (define-syntax-rule-public (name . args) . rest)
  (begin
    (define-syntax-rule (name . args) . rest)
    (export name)))

to

(define single-rule-macro-signature (make-object-property))

(define-syntax-rule (define-syntax-rule-public (name . args) . rest)
  (begin
    (define-syntax-rule (name . args) . rest)
    (set! (single-rule-macro-signature (module-ref (current-module) 'name))
          'args)
    (export name)))


and then use that in the doc autogeneration.

That being said ... a quick git grep shows only one site, make-relative,
where this could be somewhat useful. In your shoes, I would not bother
doing this and just mention the signature in the docstring itself in
plain English.

Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]