I can appreciate the value of explicitness (both from a teacher and a student perspective). I took the apparent lack of haskell-like pattern matching (henceforth just patter matching) as a rational design decision and wouldn't question it, normally. But one of my students actually tried to pattern match on a list, and it didn't work, so I thought I'd ask if there isn't a way to do it after all.
> I think it would be really interesting to conduct a user study on how beginners fare with pattern-matching
The interesting thing is that the student hasn't programmed before and only saw bits of C# from his friends' homeworks. Maybe he misunderstood the way I've demonstrated the cases construct, or maybe I'd explained it badly, but nonetheless, he seemed to find pattern matching quite intuitive. Intuitive enough to be bummed when he found out Pyret doesn't support it.
> I'm curious where users on this list find pattern-matching useful or essential.
This will come as a surprise, but having "unrestricted" (i.e. pattern-matching-equipped) cases would make it simpler to explain when to use cases and when to use simple if-else. The whole "desctructuring" stuff is all nice, but the students don't really see the benefit of
cases (List) list:
| empty =>
...
| link(first, rest) =>
first + call(..., rest)
end
compared to
if is-empty(list):
...
else:
list.first + call(..., list.rest)
end
Especially since it's shorter, familiar and just as expressive (we're not doing custom datatypes yet). The value proposition isn't good enough.
And to be honest, I'm not sure how to explain it to them. I tried the exhaustiveness argument, the explicitness argument, but... I don't think they bielive me, if you know what I mean. But that's probably my fault and not cases'.
Dne pondělí 12. října 2020 v 19:06:10 UTC+2 uživatel Shriram Krishnamurthi napsal: