emacs-devel
[Top][All Lists]
Advanced

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

Re: Regexp bytecode disassembler


From: Eli Zaretskii
Subject: Re: Regexp bytecode disassembler
Date: Sun, 22 Mar 2020 16:12:47 +0200

> From: Štěpán Němec <address@hidden>
> Cc: address@hidden, address@hidden
> Date: Sat, 21 Mar 2020 21:44:49 +0100
> 
> On Sat, 21 Mar 2020 22:30:49 +0200
> Eli Zaretskii wrote:
> 
> >> Do you mean you would prefer to use `cond' and rewrite all those clauses
> >> to something like the following?
> >> 
> >> (cond
> >>  ((eql opcode 0) (cons 'no-op 1))
> >>  ((eql opcode 1) (cons 'succeed 1))
> >
> > Yes.

(Btw, I'd use '=' here instead of 'eql', after verifying the value is
a number and rejecting non-numbers.)

> >> Maybe readability is much more subjective than I thought, but I find the
> >> latter very suboptimal, to say the least.
> >
> > Why "suboptimal"?
> 
> It's unnecessarily verbose and most of that is just repetition, i.e.
> noise, which makes it harder to read. It _begs_ to be rewritten with
> (p)case. :-)

In that case, it's the other way around IMO: using pcase here is like
firing cannons at birds -- it's un-economical (a.k.a. "suboptimal").

Please think about people who are not 100% at home with advanced
macros such as pcase: they will have a harder time understanding what
the code does.  This is especially relevant to this feature, since it
is quite probable that it would have been used by someone working on
the Emacs regex code, so Lisp proficiency may not be guaranteed.  That
is one reason why I asked to have the code prominently commented and
documented.

> >> Also, isn't "just selecting from a list of fixed values" precisely the
> >> reason to use some sort of case/switch instead of the general `cond'?
> >
> > 'cond' _is_ a case/switch construct.
> 
> I have to disagree. `cond' is a general conditional construct: all the
> clauses are completely independent, testing for anything, whereas in a
> `case' you have one object that is tested against each clause. Which is
> precisely the case here.

Then the same applies to pcase.

(Sadly, all this is now a moot point.)



reply via email to

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