-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rat Pats? #43
Comments
Would it make sense to have numeric splices? E.g.
You could of course write If we add support for signs in rational literals, we can also throw them in |
Gut feelings:
|
Fractional parts make rounding easy. If you know you may only have
But then again maybe that's better solved by a primitive. Good point about the antiquote. We just need to accept identifiers or literals. |
I guess we need to decide whether |
Is there a bar in this bikeshed? |
More gut feelings: I think I would be surprised if 2/2 wasn't matched by n/2. The other behavior should be achievable by adding a guard |
So when we write I'm surprised if |
What if we only look for integer |
There are division by 0 issues, but there ought to be some perks for working in a field. I can't help but think that Using |
I guess we ought to do guards. But that opens another can of worms... |
Or we could write |
I think
is kind of cute, but
does not match |
Why not? |
Because the fractional part of |
We may be talking past each other. I would expect:
So I would absolutely expect That's why I was talking about splices earlier: I would expect |
What's |
I expect |
It's entirely possible that this splitting operation is a good idea, but using the decimal point as its notation is not. |
Indeed. A conservative option is to follow Haskell and not allow pattern matching on rational numbers, ie leave all that for the right/guards on the left, and just introduce notion for matching a number. |
Yes, that's the bare minimum. It's funny, for strings that's
We should be careful not to create hostages to fortune. We can certainly have a boolean function which tests for being a number, and then the question is how to guard by that. |
I still don't understand the argument against Similarly As for matching against a number, I guess |
It's a hack, but we might just get away with it. We need to notice when what is right of the dot is a literal mantissa. |
Would we like patterns for rational numbers? If so, what are they? We can currently test whether a value is a particular constant. Of course, we can do a bunch of stuff with right-programming. We could leftify that by adding guards. But is there any value to making the pattern language more expressive? (Haskell's
n+k
patterns are a data point in this space, but they were always perplexing.)We could consider
It's a bit late for an April Fool, but I think it would be hilarious to make
mean the same as
We should be guided by power-to-weight ratio, and by readability concerns.
I guess we should do infix first.
The text was updated successfully, but these errors were encountered: