From: Matt Wette <matt.wette@gmail.com>
To: guile-user@gnu.org
Subject: Re: 2 macros in one expression
Date: Sat, 15 Apr 2023 06:49:30 -0700 [thread overview]
Message-ID: <4187fdcf-5bee-8e9d-3ec1-19cc55e36fc3@gmail.com> (raw)
In-Reply-To: <CADEOadePgDYTU=x4VOiQOZdqVcNffZmvK26pos=o=KTcEVDGOw@mail.gmail.com>
Did you try using the following?
(define-syntax $nfx$
(syntax-rules (<-)
((...
On 4/14/23 4:02 AM, Damien Mattei wrote:
> hello,
>
> i have 2 macros used in one expression like this:
> scheme@(guile-user)> (define i 2)
> scheme@(guile-user)> {i <- i + 1}
> and i got this error:
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> i use SRFI-105 so :
> '{i <- i + 1} expand in:
> ($nfx$ i <- i + 1)
>
> and i'm expecting $nfx$ to be called but none of this happens:
> scheme@(guile-user)> ($nfx$ i <- i + 1)
> While compiling expression:
> Syntax error:
> unknown location: source expression failed to match any pattern in form <-
>
> it seems to be the <- macro and i do not understand why?
>
> any idea?
>
> macros are defined like this for the beginning:
> ;; from file assignment.scm
> (define-syntax <-
>
> (syntax-rules ()
> ;; special form like : (<- ($bracket-apply$ T 3) ($bracket-apply$ T 4))
>
> ;; one dimension array, example: {a[4] <- 7}
> ;; $bracket-apply$ is from SRFI 105 bracket-apply is an argument of
> the macro
> ((_ (bracket-apply container index) expr)
>
> ....
>
> ;; from file scheme-infix.scm
> (define-syntax $nfx$
> (syntax-rules ()
>
> ((_ ident opspecial term1 op term2) (cond ((or (equal? (quote
> opspecial) (quote <-)) (equal? (quote opspecial) (quote ←)))
> (begin
> (display "$nfx$") (newline)
> (opspecial ident (op term1 term2)))) ;; {ident <- {term1 op term2}}
>
> ...
>
>
> it is in a module like this:
>
> (define-module (Scheme+)
>
> #:use-module (growable-vector)
> #:use-module (srfi srfi-69) ;; Basic hash tables
> #:use-module (srfi srfi-31) ;; rec
> #:export ($nfx$ def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ & condx
> <> ≠ ** <v v> ⇜ ⇝ repeat)
> #:replace (do when unless))
>
>
>
> (include-from-path "def.scm")
> (include-from-path "array.scm")
> (include-from-path "set-values-plus.scm")
> (include-from-path "apply-square-brackets.scm")
> (include-from-path "assignment.scm")
> (include-from-path "declare.scm")
> (include-from-path "condx.scm")
> (include-from-path "block.scm")
> (include-from-path "not-equal.scm")
> (include-from-path "exponential.scm")
> (include-from-path "while-do-when-unless.scm")
> (include-from-path "repeat-until.scm")
> (include-from-path "scheme-infix.scm")
>
> if it can help.
>
> Regards,
> Damien
next prev parent reply other threads:[~2023-04-15 13:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 11:02 2 macros in one expression Damien Mattei
2023-04-14 14:49 ` Damien Mattei
2023-04-14 19:36 ` Damien Mattei
2023-04-15 11:35 ` Damien Mattei
2023-04-15 13:49 ` Matt Wette [this message]
2023-04-15 14:18 ` Damien Mattei
2023-04-15 14:45 ` Damien Mattei
2023-04-15 16:15 ` Damien Mattei
2023-04-15 16:25 ` Damien Mattei
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=4187fdcf-5bee-8e9d-3ec1-19cc55e36fc3@gmail.com \
--to=matt.wette@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).