What use is `case` sneak- binding?
Richard O'Keefe
raoknz@REDACTED
Thu Aug 19 08:43:22 CEST 2021
What Karl Velicka said. With knobs on. I honestly haven't the least
idea what the question is.
Perhaps the whole point is that pattern matching and guard testing in "case"
ISN"T in any way different from pattern matching and guard testing in
functions, "fun",
or "receive".
It may be useful to recall that there was a time when Erlang did not
have "fun" or list
comprehensions, and the rule was utterly simple: the scope of a variable was the
whole clause it appeared in, with NO nested scopes. This was
inherited from Erlang's
parents Prolog and Strand-88. I actually had a half-written paper
completely destroyed
by the addition of "fun" in Erlang, The rule I would have liked to see
for "fun" and list
comprehensions is that the *scope* of a variable would have continued to be the
whole clause, but just as
if ... -> X = 1
; ... -> Y = 2
end
might not bind X or Y, making X and Y still *visible* outside the "if"
as the same variables
but UNAVAILABLE because they might not be bound, so
fun (X) -> Y = X end .... Y
should have meant that one variable Y was involved, it just couldn't
be USED at the last
position because it might not be bound. But nobody asked me.
This may or may not have anything to dow ith your question. I can't tell.
On Thu, 19 Aug 2021 at 00:18, Karl Velicka <karolis.velicka@REDACTED> wrote:
>
> Hi Michael,
>
> Apologies if I'm just missing something obvious or I'm missing some key context, but to me your message/question contains a lot of unfamiliar terminology and hyperbole which makes it hard to understand what you're getting at.
>
> What is "sneak-binding"? Sneaky "slot machine" nature?
>
> It would be really helpful if you could give a more concrete example of what you dislike about case (the less ellipsis the better!), and a similar piece of code rewritten following your suggestion (I _think_ you're making a suggestion without message, but I'm not actually entirely sure..)
>
> Thanks,
> Karl
>
> On Wed, 18 Aug 2021 at 13:04, Michael P. <empro2@REDACTED> wrote:
>>
>> What use is the sneaky "slot-machine" nature of
>> how `case` treats pattern unboundies
>>
>> Does it simplify the implementation of `case`?
>>
>> OC, `case` has to _try_ to match the patterns and cannot
>> simply dump every new binding. Unbinding on badmatch or
>> repeating the matching or transferring new bindings
>> after success in some subscope might complicate
>> the implementation. And sounds a bit like backtracking,
>> and Erlang was designed with a 'no backtracking' premise ...
>> yet there cannot be any side-effects as the only expression
>> allowed in patterns is 'variables', the `case` switch
>> is evaluated only once anyway ... and now I have shipped
>> off the brink of my tiny world.
>>
>> Giving `case` the '(let)' after 35 years hits "the legacy wall".
>>
>> What would one lose when the "slot-machine" scared
>> one into some
>>
>> Switch = ...,
>> Result = (fun Case(...) when ... -> ...;
>> Case(...) when ... -> ...
>> end)(Switch),
>> ?
>>
>> ~M
>>
>> --
>>
>> Normality is merely a question of quantity,
>> not of quality.
>>
>> Normalität ist nur eine Frage von Quantität,
>> nicht von Qualität.
>>
>>
>>
More information about the erlang-questions
mailing list