Fundamental differences around patterns

Michael P. empro2@REDACTED
Wed Aug 18 12:36:20 CEST 2021


Boundies and unboundies in patterns are
"fundamentally different" (Raimo's wording).

"And explicit is better than implicit." (Zen of Python)

I might have identified three more fundamental differences.
(The first one might have been done with too quickly.)

I will use `val` as a pattern boundie annotation;
`val` says what it means and is somehow related to `var`,
which is, kind of, implied for unboundies
by the pattern context.

And it does not conjure up detrimental associations
in Elixir programmers.

-------------

At least someone said they would often repeat a variable within patterns,
so let B have no binding and us be explicit and consistent:

    % scope 1
    {B, val B} = Expr % scope 2 (within match operation)

There is a fundamental difference between
the first and the second occurrence of B.
It exists only within the match operation.
But annotation could warn of redundancy
(naming of term instead of that term's function).

Annotate?

-------------

A will already be bound by case "sneak-export"
and will be evaluated to be matched with the `case` result;
and it might not be what was intended;
so, to be explicit and consistent:

    val A = case 1 of A -> A end.

Annotate?

-------------

Being a "sneak-export" makes `U` fundamentally different
from the other unboundies:

    %% Let A, B, U be unbound.
    case Expr of
        {var U, A} when A ... -> Expr_seq_1;
        {var U, B} -> Expr_seq_2
    end,

Explicit is better than implicit, so: annotate?

Alternatives: var, let, sneak, push, shove, ...

(Related to, but possibly better kept apart from 'val' ...)

-------------

I fail to assess how fundamental all this is:

    P = ...,
    V = ...,
    F = fun F(V) ->
            N = ...,
            F({V, N, super V, super P})
        end

Let alone `super F` ...

OC, there are alternatives:
    super, prev, ext, imp, grab, close, ^

The last one is git-y, but is bound to conjure up
detrimental associations in Elixir programmers.

Related too, but possibly better kept apart from 'val' ...

-------------

Explicit is better than implicit, but is the binding
implied by pattern context explicit or implicit or between-we-sit?

I am not sure that there is much problem to be solved,
much trouble being prevented by the nature of Erlang.

OC, for the 733t wizard there is no problem at all,
but the nature of Erlang might be altered to prevent
even more trouble ...

~M

--

"So, here we go again
 Searching for the truth
 Until the twelfth of never"






More information about the erlang-questions mailing list