-
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
Make "external f: 'a => 'b;" shortcut for empty string #2537
Conversation
60d39f2
to
9f1ada2
Compare
@@ -405,9 +405,10 @@ type reactClass; | |||
|
|||
/* "react-dom" shouldn't spread the attribute over multiple lines */ | |||
[@bs.val] [@bs.module "react-dom"] | |||
external render: (reactElement, element) => unit; | |||
external render: (reactElement, element) => unit = | |||
"render"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is regressing from #2464 in that the printer shouldn't print the = "render";
part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure as the input for this particular output looks like this
/* "react-dom" shouldn't spread the attribute over multiple lines */
[@bs.val] [@bs.module "react-dom"]
external render : (reactElement, element) => unit = "render";
And the tests are passing, too. There's something else failing on the CI though which I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we agreed in the last PR that if the ident and the primitive name agree we can drop it on the floor, but I could be misremembering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or did I misunderstand the assignment from Bob? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to drop it if they are the same too btw. But I don't know all the in & outs of bs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn’t read the discussion in the other issue.
I disagree with the outcome, but oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you all know this, but I still want to write this out for anyone following this discussion.
@anmonteiro I think we agreed in the last PR that if the ident and the primitive name agree we can drop it on the floor, but I could be misremembering
With this behavior, it would be a breaking change for BuckleScript.
The recommendation is to always explicitly write the string value, even if the identifier matches the value itself.
[@bs.val] [@bs.module "react-dom"]
external render : (reactElement, element) => unit = "render";
Previously, you could leave it out blank as well, but this will now yield a warning that this is discouraged. As @bobzhang said, the reason is to prevent binding errors due to quick renaming of the identifier (with the punning, you wouldn't even know what's going on, especially if you are newcomer and never used the string representation for some reason).
Why does [@bs.obj]
require a = ""
then? This seems to be documented here:
[@bs.obj] external route: (
~_method:string,
~path:string,
~action:(list(string) => unit),
~options:Js.t({..})=?,
unit
) => _ = "";
Note: the = "" part at the end is just a dummy placeholder, due to syntactic limitations. It serves no purpose currently.
So i guess the whole goal of this general external syntax feature is to get rid of this confusing [bs.obj]
syntax?
The diff looks good to me. |
Thanks for the clarification @ryyppy 👌 Can someone point me in the direction of how can I make the CI happy? Menhir version seems to be incompatible? |
CI breaks for unrelated reasons (also happens on a change-nothing diff which used to build OK). |
@anmonteiro I think you and I agree on what would be ideal here. Punning is nice because if you omit a string, there's really only one thing you could ever want it to be - punned. The only exception is if you have to be using the current version of bs's ppx (which many are). Since breaking people isn't an option, we need to find a way to get to the ideal state without breaking people. Do you have an alternative suggestion to get to the ideal state of punning without breaking anyone? There's a couple of changes that we are making a list of that need to be coordinated with a bs release. One is fixing label mangling, and the other is this punning. I'm keeping a list of these things. |
@bobzhang What would be involved in making the next release of bs gracefully ignore the contents of the string when using bs.obj? It seems like that would be a non-breaking BS change, that allows us to add this feature back. Without bs being graceful in allowing that, it is currently eating up a nice syntactic real estate for non-bs use cases (needlessly?) |
With this update, isn't the change list for 3.6.0 incorrect?
(putting aside the typo, it should read I saw that and expected to be able to remove the |
@TheSpyder jup, i opened a PR a few days ago #2540 ... hasn't been merged yet |
This is a followup to #2464 based on the discussion in there.