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

String interpolation #124

Open
KCreate opened this issue Dec 21, 2016 · 2 comments
Open

String interpolation #124

KCreate opened this issue Dec 21, 2016 · 2 comments
Labels

Comments

@KCreate
Copy link
Collaborator

KCreate commented Dec 21, 2016

let name = "world"
let message = "up"
"hello #{name} whats #{message} result: #{2 + 2 * 2}"

becomes:

"hello " + (name).to_s() + " whats " + (message).to_s() + " result: " + (2 + 2 * 2).to_s()

The parser will parse it as a StringInterpolationNode and a seperate transformation pass will do the rewriting.

@KCreate KCreate added the Syntax label Dec 21, 2016
@ghost
Copy link

ghost commented Apr 22, 2017

@KCreate I would keep the top one, because it saves us the (, ) and .to_s()

@KCreate
Copy link
Collaborator Author

KCreate commented Apr 22, 2017

Indeed, the top snippet is what this issue proposes. These snippets demonstrate how the parser would effectively transform the top snippet into the lower snippet.

"hello #{name}"

// gets rewritten by the parser to:

"hello " + (name).to_s()

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

1 participant