-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consistent powerful pattern matching everywhere? #49
Comments
This is a throwaway issue. This needs a real proposal or some examples. For functions, we would need to group patterns by type and convert the dynamic part (the part the type system doesn't model) to run-time checks:
becomes
This is really complex and makes it perhaps too easy to write overlapping or conflicting definitions. For example, you wouldn't implement Another problem is that we don't have record literals, or structurally-typed records. So something like "name::String, age::Number" is not a type. As I said at one point, we could add records like this, which are basically tuples with named components. These are to keyword arguments exactly what tuples are to positional arguments, which has a certain elegance. But it just seems like too many features. |
These are the reasons why I made this a v2.0 issue and a speculative one. It's really just a placeholder for keeping the possibility in mind. Maybe we have a much more limited notion of pattern matching, but using the same approach for case statements and catch blocks seems sensible. We already have limited destructuring for tuples. |
+1 here :) |
I'd rather see something along the lines of :
|
Yes that syntax makes more sense. |
I don't think we need an issue to keep track of this idea. |
* =Use abstract type, not union * =Some abstractions
More thorough detection of atsign-doc expressions
General pattern matching a la Magpie (discussion here) used for function dispatch, destructuring, switch case dispatch, and exception handling. See the brief email thread on the subject. We could still really use some pattern matching. The hardest part would likely be integrating it with multiple dispatch.
The text was updated successfully, but these errors were encountered: