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

Improved BuckleScript method call syntax #941

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Improved BuckleScript method call syntax #941

wants to merge 3 commits into from

Conversation

SanderSpies
Copy link
Contributor

#849

Changes Foo##bar into Foo."bar"

Note that ## still needs to used for scenario's like: Foo##(something."else").

Also #= has gotten an extra post space during printing as it otherwise will fail to be idempotent.

@chenglou
Copy link
Member

chenglou commented Jan 8, 2017

Context: we're sticking with #= for the moment.

cc spam @bsansouci @Schmavery @jordwalke @yunxing, adding a space after #= ok? I recall some precedence problems around it?

Note that ## still needs to used for scenario's like: Foo##(something."else").

I don't think @bobzhang made such thing work. This compiles to something weird: https://bloomberg.github.io/bucklescript/js-demo/?gist=0d4169c80f571302b5a163ee01556a7e

@SanderSpies
Copy link
Contributor Author

@jordwalke mentioned a better form: Foo["bar"]["more"]. I'll update this PR unless there are objections.

@chenglou
Copy link
Member

chenglou commented Jan 8, 2017

That'd be a bit more tedious than ## and might mislead people into doing foo[stringRef] (though we can warn against that)

@SanderSpies
Copy link
Contributor Author

It requires also some more work, so let's keep it as is.

@bobzhang
Copy link
Contributor

bobzhang commented Jan 8, 2017

@chenglou your example probably is a bug on BuckleScript, it should fail with a nice error msg

@bobzhang
Copy link
Contributor

bobzhang commented Jan 8, 2017

How about using '.=' instead of '#='

@SanderSpies
Copy link
Contributor Author

@bobzhang could easily be added (did a quick experiment).

preview##style##border#=(
Js.string "1px black dashed"
);
preview."style"."border"#= (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something goes wrong here.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

What's wrong exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, I was looking wrong.

@Schmavery
Copy link
Contributor

Adding a space (before and) after #= shouldn't result in any parsing issues. In fact, it should fix #856

@SanderSpies
Copy link
Contributor Author

Added support for .=.

@chenglou
Copy link
Member

Is this ready?

@SanderSpies
Copy link
Contributor Author

Yes, ready for review

@chenglou chenglou mentioned this pull request Jan 15, 2017
@chenglou
Copy link
Member

Fack. cc @yunxing is this good to go? If it is, @bobzhang everything's ready on BS' side right?

@bobzhang
Copy link
Contributor

this is good, would you do a sanity check on your side that no # character in method name

@SanderSpies
Copy link
Contributor Author

Updated with extra check for hash within method name.

@yunxing
Copy link
Contributor

yunxing commented Jan 30, 2017

The parser && printer part looks good to me.

@chenglou Feel free to merge this if the syntax also looks good to you.

@chenglou
Copy link
Member

chenglou commented Feb 1, 2017

This PR works but completely wrecks editor highlighting.

screenshot 2017-02-01 01 01 20

screenshot 2017-02-01 01 02 00

I can fix this for atom (and I guess vscode by extension), @jordwalke what about vim? cc @yunxing for emacs

@chenglou
Copy link
Member

chenglou commented Feb 1, 2017

Will work on making the highlighting work then merge this tomorrow.

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.

7 participants