-
Notifications
You must be signed in to change notification settings - Fork 428
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
Alternative syntax for method calls - changes foo#bar to foo..bar. #580
base: master
Are you sure you want to change the base?
Conversation
I'd like to hear what others think of this. |
I'm new here, and to OCaml, but this seems very counter intuitive to me. I'd expect it to be a range, but not a method call. I think I might have seen someone suggesting |
@tadeuzagallo Agree that it looks like a range, however using |
@SanderSpies Oh, didn't think about it... but still, between the two, I like |
@SanderSpies Thanks for implementing this. |
@yunxing looks good to me. @tadeuzagallo what do you think? |
I am following activity on
Also, as I pointed out in #557 (and was pointed out independently in #568), it would be nice if the changes in the reason syntax did not make the code not-understandable by people accustomed to the OCaml syntax (or less compatible in a sense). |
One thought: if @braibant : Many of these proposed changes are just pull requests, many of them don't arise from any official discussions - they're just people getting their ideas out there in the best possible way - code. We welcome pull requests, even if they're silly or just a means of learning. When syntactic changes like this are very local, and have ramifications to the wider syntactic real estate, that will come up in discussion on the diff and it's a really great way for people to learn. So I'd say we can take individual, smaller PRs with a grain of salt and people who send them understand this as well. Then, in addition to that, as you suggested, we should have larger, more holistic conversations for big topics such as "named arguments" (you can see we have existing threads for those which cover a ton of edge cases and considers how it effects the entire grammar). I am curious about one comment you made - that making the syntax immediately recognizable to OCaml programmers should be a goal. I agree it would be nice, but surely that comes at the cost of making it more difficult to recognize for non-OCaml programmers. If we have to choose one of those audiences to cater to, which one do you suggest and why? A few things to consider:
|
What about Actually this Edit: what about |
Thanks for the ideas, @bsansouci! Another extreme idea I had thrown around earlier was that records would look more like variants, in that they have all leading capital letters. It makes sense when pattern matching or creating variants with records inside - capitals become the visual language for "pattern matchable thing": let somePoint = Some {X: 0, Y: 100};
let res = switch {
| None => 0
| Some p => p.X + p.Y
};
/*
* This is actually an object, not a record.
*/
let myObject = {
myMethod: fun a b => a + b,
private myPrivateMethod: fun a b => a + b
};
let result = myObject.myMethod 10 20;
let result = myObject.myPrivateMethod 10 20; I decided against it because records are faster than objects (a better default) and it makes punning weird ( Just my current thoughts, that I'm totally flexible on. |
Fixes #523
Also related to #366