Skip to content
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... = "" optional in reason syntax #2464

Merged
merged 1 commit into from
Dec 14, 2019

Conversation

romanschejbal
Copy link
Contributor

@romanschejbal romanschejbal commented Oct 10, 2019

Fixes #2422

@jordwalke
Copy link
Member

Great change!

@anmonteiro
Copy link
Member

anmonteiro commented Oct 28, 2019

@romanschejbal I made another pass at this -- it seems that you still need to handle the .rei case.

Other than that this is really shaping up!

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to go.

@romanschejbal thanks again for working on this. I think a good next step could be to parse external x: ... = ""; into external x .. = "x" and avoid having empty strings in the AST at all. I think this would get us rid of the bucklescript warnings.

@romanschejbal
Copy link
Contributor Author

Thanks to you for the intro and help! And yes, that makes total sense. I will look into it when I get some time. :-)

@romanschejbal
Copy link
Contributor Author

I think this one is now good to go. It removes those empty strings during parsing phase so we don't get bs warnings. Do you mind taking another look @anmonteiro ?

And sorry if the rebase messed up the code-reviewing.

Thanks

@jordwalke jordwalke merged commit ede1f25 into reasonml:master Dec 14, 2019
@jordwalke
Copy link
Member

Thank you for your contribution @romanschejbal !

@bobzhang
Copy link
Contributor

bobzhang commented Jan 28, 2020

I think this is good to go.

@romanschejbal thanks again for working on this. I think a good next step could be to parse external x: ... = ""; into external x .. = "x" and avoid having empty strings in the AST at all. I think this would get us rid of the bucklescript warnings.

In bs, bs.obj expect string to be empty, that's why I made such feature request.
If you do the punning here, it will still make refactoring fragile: change x also change the underlying js names which defeats the purpose of warning

@jordwalke
Copy link
Member

So what is the desired behavior? Should it default to empty if there is no string contents supplied?

@jordwalke
Copy link
Member

I do like the behavior of having external x : typ; defaulting to = "x". It is really nice for c bindings, but I agree we cannot make a breaking change without coordinating a major version bump. In future versions of bs, is it possible to relax the requirement that the string content be empty in the AST? Is there a reason why bs.obj cannot ignore the string content? (Again, in the future - not right now because of the breaking change).

@bobzhang
Copy link
Contributor

See my comments on punning: it is fragile to refactoring (both for C and JS)
So the desired behavior should be empty string, but I am unclear why it broke the CI since we did not use this feature yet

@romanschejbal
Copy link
Contributor Author

Yes that's what's happening here. Anyway, I'm happy to create another PR rn that'll preserve the empty string if that's what you'll settle on. :)

@bobzhang
Copy link
Contributor

@romanschejbal thanks for looking into it.

desired behavior

  • external f : 'a => 'b ; is a short-cut for empty string
  • no punning involved

@romanschejbal
Copy link
Contributor Author

romanschejbal commented Jan 28, 2020

@bobzhang see the new PR pls, hope it's correct! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make = "" optional in reason syntax
5 participants