Published: pattern matching
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Apr 19 15:00:04 UTC 2017
----- Mail original -----
> De: mark at io7m.com
> À: "Brian Goetz" <brian.goetz at oracle.com>
> Cc: "Remi Forax" <forax at univ-mlv.fr>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Mercredi 19 Avril 2017 16:48:36
> Objet: Re: Published: pattern matching
> On 2017-04-19T10:34:31 -0400
> Brian Goetz <brian.goetz at oracle.com> wrote:
>>
>> Yes, we considered it. But the reason for preferring var here is not
>> necessarily just compiler complexity; it's that it's weird for
>>
>> if (x matches Foo(y))
>>
>> to be a _declaration_ for y. Java developers are not used to that.
>
> Strongly agree here. I've taken a few programmers with no Haskell
> experience through introductions to Haskell and one thing that reliably
> trips them up is that patterns introduce bindings in a way that's not
> totally explicit.
>
> f :: Nat -> Nat
> f Zero = ...
> f (Succ z) = ...
>
> "Where is this z variable declared?! Oh, right..."
>
> M
while i do not disagree, making things explicit is usually a win,
i see the same issue with my student the first time they see the lambda syntax (z) -> ...
given that the proposed syntax for the pattern matching also uses '->', it maybe less hard.
Rémi
More information about the amber-spec-observers
mailing list