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

Script lambdas can't handle line break appropriately #24

Open
anatoliykmetyuk opened this issue Apr 27, 2014 · 2 comments
Open

Script lambdas can't handle line break appropriately #24

anatoliykmetyuk opened this issue Apr 27, 2014 · 2 comments
Labels

Comments

@anatoliykmetyuk
Copy link
Collaborator

Consider following program:

val script = [doSomething]
println(x)

In AST view, it will translate to:

val `script` = subscript.DSL._script(this, scala.Symbol("<lambda>"))(ScriptApply(<empty>, List(doSomething))).println(x);

Apparently, ".println(x)" at the end is not what we want.

There are 2 workarounds, both clumsy though:

val script = [doSomething];

println(x)

(note that both semicolon and extra line break are required, or it will not work)

Or:

val script = ([doSomething])
println(x)
@anatoliykmetyuk
Copy link
Collaborator Author

By the way, construct like:

anchor launch [doSomething]

also doesn't work. To make it work, we need to do it as follows:

anchor launch ([doSomething])

@AndreVanDelft
Copy link
Owner

Unhappy with the parsing of println(x)
I think this should behave as comparable normal Scala code does.
If you had instead of [doSomething] a "normal" Scala object, would it be compiled the same?

I understand that in

anchor launch [doSomething]

the open bracket is seen as the start of a type parameter list. We cannot improve this behaviour I am afraid.

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

No branches or pull requests

2 participants