From: Vijay Marupudi <vijaymarupudi@gatech.edu>
To: Damien Mattei <damien.mattei@gmail.com>, guile-user <guile-user@gnu.org>
Subject: Re: reserved-keyword in macro
Date: Wed, 02 Feb 2022 19:52:37 -0500 [thread overview]
Message-ID: <87bkzou5yi.fsf@vijaymarupudi.com> (raw)
In-Reply-To: <CADEOadcNiPsKWHuBOqHtjJJO8_aPi7aTi-vucgMYoS+1csRrMQ@mail.gmail.com>
Hi Damien,
I tried to run the code you provided. I ran
-----------------------------------------------------------------
(define-syntax <-
(syntax-rules ($bracket-apply$)
((_ ($bracket-apply$ container index) expr)
(let ((value expr)) ;; to avoid compute it twice
(cond ((vector? container) (vector-set! container index value))
((hash-table? container) (hash-table-set! container index value))
(else (array-set! container index value)));)
value))
((_ ($bracket-apply$ array index1 index2 ...) expr)
(let ((value expr))
(if (vector? array)
(array-n-dim-set! array value index1 index2 ...)
(array-set! array index1 index2 ... value));)
(newline)
value))
((_ (var ...) expr)
(begin
(display expr) (newline)
(let ((expr-list (call-with-values (lambda () expr) list)))
(assign-var (var ...) expr-list)
expr-list)))
((_ var expr)
(begin
(set! var expr)
var))
((_ var var1 var2 ...)
(<- var (<- var1 var2 ...)))))
(define T (make-vector 5))
(<- ($bracket-apply$ T 2) 1)
-----------------------------------------------------------------
After I ran that, T was
#(#<unspecified> #<unspecified> 1 #<unspecified> #<unspecified>)
Is that was you are looking for?
> "A literal matches an input expression if the input expression is an
> identifier with the same name as the literal, and both are unbound13
> <https://www.gnu.org/software/guile/manual/html_node/Syntax-Rules.html#FOOT13>.
> " as $bracket-apply$ is already bind to a definition the pattern will
> not be matched:
It's possible, as in my case, I did not have it bound, and it seems to
have worked the way you expected?
~ Vijay
next prev parent reply other threads:[~2022-02-03 0:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 10:13 reserved-keyword in macro Damien Mattei
2022-02-02 10:33 ` Maxime Devos
[not found] ` <CADEOaddzjFbSYvVGEOkrSrjHSZvUkqC9beiRw29jbH3XHeRkZw@mail.gmail.com>
2022-02-02 13:02 ` Fwd: " Damien Mattei
2022-02-02 21:23 ` Damien Mattei
2022-02-02 21:38 ` Damien Mattei
2022-02-03 0:52 ` Vijay Marupudi [this message]
2022-02-03 10:09 ` Damien Mattei
2022-02-04 8:21 ` Damien Mattei
2022-02-04 16:24 ` Damien Mattei
2022-02-04 16:44 ` Maxime Devos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkzou5yi.fsf@vijaymarupudi.com \
--to=vijaymarupudi@gatech.edu \
--cc=damien.mattei@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).