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

Allow string concatenation when defining const values #3208

Open
george-grec opened this issue May 28, 2024 · 10 comments · May be fixed by #3318
Open

Allow string concatenation when defining const values #3208

george-grec opened this issue May 28, 2024 · 10 comments · May be fixed by #3318
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium

Comments

@george-grec
Copy link

This is currently not valid syntax:

pub const foo = "foo"
pub const foo_bar = foo <> "bar"

It would be great if this would work!

@slightlybelowzen
Copy link

slightlybelowzen commented May 29, 2024

Just wondering why this isn't allowed? Is there a reason (since it seems fairly reasonable) or was it just left to be implemented later?

@lpil
Copy link
Member

lpil commented May 29, 2024

Thank you! Good suggestion.

@slightlybelowzen It's just something no one has implemented. The stuff that people decide to work on is the stuff that gets done.

@slightlybelowzen
Copy link

slightlybelowzen commented May 30, 2024

Fair enough, I could try to hack something together this weekend, see if I get anywhere😀

@lpil
Copy link
Member

lpil commented May 30, 2024

Wonderful! Thank you

@lpil lpil added the help wanted Contributions encouraged label May 31, 2024
@DeviousStoat
Copy link

I started looking into that. Not sure if @slightlybelowzen has started something too but it doesn't matter too much to me if my code doesn't go anywhere, this is a pretty cool task to start getting familiar with the code.
I just had a question @lpil, do we want to support any binary operation in const statements or just the string concatenation?
If foo <> "bar" is allowed shouldn't any operation on consts be allowed too?

pub const foo = 5
pub const foo_bar = foo + 5

@lpil
Copy link
Member

lpil commented Jun 10, 2024

Just concatenation for now as it does not require compile time code execution to implement.

@DeviousStoat
Copy link

why doesn't concatenation require compile time code execution? we should inline the concatenation operation? If so then what's the difference with inlining other operations?

@lpil
Copy link
Member

lpil commented Jun 11, 2024

Because that's how Erlang works.

@DeviousStoat
Copy link

yeah I don't know I was more thinking about the javascript part. sorry about the questions, I was just trying to understand a bit more. I will try to make a PR anyway, we'll see

@lpil
Copy link
Member

lpil commented Jun 12, 2024

Thank you 💜

@DeviousStoat DeviousStoat linked a pull request Jun 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants