emacs-devel
[Top][All Lists]
Advanced

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

Re: Question on pcase


From: Stephen Berman
Subject: Re: Question on pcase
Date: Sat, 24 Oct 2015 21:10:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

On Sat, 24 Oct 2015 17:47:19 +0000 Alan Mackenzie <address@hidden> wrote:

>> >  ;; This is a pattern form that allows you to match a pattern PAT
>> >  ;; against an _arbitrary_ expression EXP.  This is not special,
>> > -;; matching PAT is done as you have learned, just against the EXP you
>> > +;; matching PAT is done as you have learned, just on the EXP you
>> >  ;; specify there, and not the EXPRESSION given to pcase at top level.
>
>> Why replace "against" with "on" here but not in the preceding line?  I
>> think "against" is usual in this context.  A somewhat better formulation
>> is this, IMO: "The only difference from the pattern matching you have
>> learned is that PAT is matched against the EXP you specify here..."
>
> Oh, no!  This is complicated, too.  

It doesn't strike me as more complicated than the original, just a bit
less stilted (to my ears).

>                                     Perhaps the best preposition for
> "match" here is "with", on the grounds that harmony is expected rather
> than a fight.  You might match one sporting team against another, but
> you'd match the colour of an item of clothing with that of another.  Or
> something like that.

"Match with" sounds out of place here.  I think "match against" is
pretty much standard in the context of pattern matching in formal or
programming languages; cf. these quotes (among many similar) from
Friedl's _Mastering Regular Expressions_ (3rd ed): 

"A collating sequence allows you to match against those characters that
are made up of combinations of other characters." (p128)

"This means that multiple regexes can match against a string, in turn
[...]." (p130)

"Thus, when trying to match 「ORA」 against FLORAL, the first attempt at
the start of the string fails (since 「ORA」 can’t match FLO)." (p148)

"Let’s consider one way an engine might match 「to(nite|knight|night)」
against the text ‘...tonight...’." (p153)

"The regex-directed NFA engine might waste time attempting to match
different subexpressions against the same text [...]." (p156)

>> > -;; If you are used to understand grammers: the above description of
>> > -;; `QPAT describes a quite simpel grammer.  You make like to try it
>> > +;; If you are used to understanding grammars: the above description of
>> > +;; `QPAT describes a quite simple grammar.  You might like to try it
>
>> I think a somewhat better formulation is this: "If you are familiar with
>> formal language grammars, the above description..."
>
> Possibly.  But that's rewriting the original, rather than correcting it.

Well, "If you are used to understanding grammars" sounds peculiar to me,
and in the context seems to mean nothing else than "If you are familiar
with formal language grammars", so I do think it more a correction than
a rewrite.  But it's up to Michael Heerdegen or whoever will maintain
this document.

Steve Berman



reply via email to

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