[erlang-questions] Guards syntax for multiple values
Tue Mar 26 07:42:31 CET 2019
I must repeat, we do not need any new syntax.
We just need the special case of lists:member/2
with a fixed-length list argument to be accepted
in a guard. This is a relatively minor change
to the compiler.
If any syntactic extension were involved,
SML/NJ allows (P1 | ... | Pn) anywhere that
a pattern is allowed.
However, this particular example strikes me as
a perfect example of something that should NOT
repeat NOT be done by pattern matching. Why?
Because "does this codepoint represent a vulgar
fraction in Unicode" is not a question with a
fixed answer. Unicode keeps on growing. The
*right* question is "does codepoint X represent
a vulgar fraction in Unicode version Y", and
you not only do not want to express that kind
of thing in code, you don't want to, because
Unicode keeps on growing, new versions keep on
coming out. You want to be able to load a new
Unicode Data release *without* rewriting your
Alternativey, this appears to be an excellent
example of code that should be *generated*, not
*written*, and who cares how hard the compiler
has to work?
On Tue, 26 Mar 2019 at 08:43, Jesper Louis Andersen <
> On Mon, Mar 25, 2019 at 8:36 PM Fred Hebert <mononcqc@REDACTED> wrote:
>> OTP-21 includes the new BIFs erlang:map_get(Key, Map) and
>> erlang:map_size(Map) for these reasons. Only lists:member is missing.
> Indeed! Though the documentation doesn't have them as "Allowed in guard
> tests". We can live without is_key, if we just test against true for now. I
> tried looking it up and the documentation didn't have them as allowed. But
> perhaps the code actually allows them if I just tried doing it?
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions