emacs-devel
[Top][All Lists]
Advanced

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

Re: Regexp bytecode disassembler


From: Štěpán Němec
Subject: Re: Regexp bytecode disassembler
Date: Sat, 21 Mar 2020 21:16:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Sat, 21 Mar 2020 21:19:16 +0200
Eli Zaretskii wrote:

>> >> +               (pcase opcode
>> >> +                 (0 (cons 'no-op 1))
>> >> +                 (1 (cons 'succeed 1))
>> > 
>> > Is pcase really needed here?  It looks like a simple cond will do.
>> 
>> Well, pcase is a lot more readable here, don't you think?
>
> No, I don't, not in this case.  You are just selecting from a list of
> fixed values.

Please forgive my intrusion, but, while I tend to agree with most of
your other comments, I find this one very surprising.

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))
  ...

Maybe readability is much more subjective than I thought, but I find the
latter very suboptimal, to say the least.

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'?

Certainly `pcase' can also be useful in more complicated use cases, but
it will expand to the cond form anyway, so I also don't see any
performance concerns.

-- 
Štěpán



reply via email to

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