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

Improve multi-line string syntax #213

Open
robinheghan opened this issue Jul 31, 2023 · 4 comments
Open

Improve multi-line string syntax #213

robinheghan opened this issue Jul 31, 2023 · 4 comments

Comments

@robinheghan
Copy link
Member

robinheghan commented Jul 31, 2023

  1. Only the line containing the closing """ should determine the indentation level to be removed.
  2. If the first character is anything but \n it should be a syntax error (The empty string, """""", is not valid)
  3. The opening and closing """ should have the same indentation level.
@robinheghan robinheghan self-assigned this Jul 31, 2023
@robinheghan robinheghan changed the title note to self: double-check the multi-line string implementation in Gren Improve multi-line string syntax Jul 31, 2023
@robinheghan robinheghan added this to the 0.4.0: Parametric Modules milestone Aug 31, 2023
@robinheghan robinheghan removed their assignment Aug 31, 2023
@robinheghan
Copy link
Member Author

Worked on by @Gauteab

@lue-bird
Copy link
Contributor

lue-bird commented Feb 21, 2024

The syntax would still be unambiguous if we use only a single " instead of three, so

text =
    "
    First
    Second
    "

instead of

text =
    """
    First
    Second
    """

Would this be more confusing than nice? I feel like it would be easier to learn/remember. Changing from single-line to multi-line string would also be more seamless.

@blaix
Copy link
Contributor

blaix commented Jul 14, 2024

Discovered this current behavior when trying to test terminal output in gren-tui:

> """
|    indented
| not indented
| """
|   
"indented\nnot indented" : String

I guess that would be fixed by this?

Only the line containing the closing """ should determine the indentation level to be removed.

Until this is done should this be labelled as a bug? Kind of makes multi-line strings unusable in places with Very Significant whitespace.

@robinheghan
Copy link
Member Author

Yes, this is a bug.

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

No branches or pull requests

3 participants