-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow labelled arguments after () when defining components using %component syntax #51
base: master
Are you sure you want to change the base?
Conversation
What happens if you partially apply a component now? |
What do you mean by "partially apply"? in this case? Mandatory props can't be left out because of the |
@glennsl this is currently valid: let testComponent = (~prop, ~prop2, ~dispatch, ()) => prop + prop2 - dispatch;
let x: (~dispatch: int) => int = <testComponent prop=1 prop2=3 />; |
That said, I think the current restriction (edit: maybe) should be lifted. Why not allow all kinds of functions (with named arguments) as
I'm also considering the future when there's div ~style:some_style () ~children:[
] as opposed to div ~style:some_style [
] I'm not sure! |
Ah, yes, sorry, of course it is. This PR doesn't change that. The generated code is exactly the same.
Just because it wouldn't say "expected labelled argument or
What kind of breaking changes do you foresee? It's pretty much just the hooks implementation isn't it? Other than that it's pretty much just an ordinary function. I would love to be able to use the last form. And probably wouldn't use the more verbose one, I'd just use Reason and JSX instead. But if the stability of the hooks implementation is the only likely breaking change, I think it ought to wait until that stabilizes. |
so why allow that ?
When you use JSX - the transformation depends on the terminating I don’t foresee any in the near future but should they arrive with two ppxes it’s way more flexible. When it comes to the PR, I’m not sure what’s the value proposition but it doesn’t introduce any problematic side effects as far as I’m concerned (as long as optional args are not allowed). Aside from the PR, I still don’t have a clear idea of where we wanna be with the ppxes, API, and interoperability (between different component flavors so to speak). |
Also bear in mind that I started on this thinking I could add positional arguments after I had two other suggestions for distinguishing them:
The first would involve reordering the function arguments, which isn't great, and the second would involve adding another extension point with associated pile of code. I suppose we could also add an attribute to tag the extra arguments with, but that kind of complexity doesn't seem anywhere near worth it:
Right, I was thinking
Optional arguments are currently allowed, but you're right, they definitely shouldn't be. I'll fix. |
55379e6
to
c4d8dc8
Compare
Rebased, banned optional args after |
c4d8dc8
to
93ca44d
Compare
I am starting to think; wouldn't it be better if you had a separate |
As a separate project or separate extension point? This is the only change I need, I'm pretty sure, and I don't see it making sense just for this. But to better support OCaml/Elm-like syntax it might make sense. That'd ne nice to have, but it's far from a requirement for what I'm trying to do. |
This allows partially applied components to be returned with JSX syntax. E.g.: