[Top][All Lists]

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

Re: syntax taste: use of unquote in macros

From: Zelphir Kaltstahl
Subject: Re: syntax taste: use of unquote in macros
Date: Mon, 30 Mar 2020 00:07:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 3/29/20 5:11 PM, Matt Wette wrote:
> Hi All,
> I'm not sure if you know about this, but there is a discrepancy in the
> way some folks define macros to use unquote (aka ,).   For example,
> > (use-modules (system base pmatch))
> > (pmatch '(foo "bar")  ((foo ,val)  (write val) (newline)))
> => "bar"
> > (use-modules (ice-9 match))
> > (match '(foo "bar")  (`(foo ,val)  (write val) (newline)))
> => "bar"
> Note the difference in the use of quasiquote (aka `) in the pattern
> for (foo ,val): match syntax uses it, pmatch does not.
> In Scheme, quasiquote and unquote always come together.
> Is pmatch syntax in bad taste?  I'm looking for opinions.
> Another example is sxml-match, which omits use of quasiquote.
> I have written a variation of sxml-match.  Should I keep the sxml-match
> usage, which keeps it compatible with sxml-match,  or adopt that
> used by (ice-9 match)?
> Matt

Hi Matt!

I'm not sure where I first read about pmatch doing the quasiquote
internally automatically and I of course had already forgotten about it,
until I read your e-mail. I remember though: When I read about it, I
thought something like: "Ehhh? That's confusing. Everywhere else you
have to quasiquote to unquote, but in pmatch it's different. Easy to
forget that and I need to remember more. I would not mind having to
write a simple quasiquote myself."

So, with my limited experience, I would definitely vote for the, in my
opinion more natural way, to have the user write the quasiquote, instead
of doing that internally. It's not saving that much time or writing
really. I understand the idea, that "if it is always done anyway, one
could save the user some typing of the same thing over and over again",
but in my opinion it is not worth it to deviate from, what one would
expect without knowing about this behavior.


reply via email to

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