I-Language-Development / I-language-rust

The I programming language is a high level programming language written in rust.
https://i-language-rust.readthedocs.io/en/latest/
MIT License
11 stars 2 forks source link

[ENHANCEMENT] Remove multiline strings #136

Closed ElBe-Plaq closed 2 weeks ago

ElBe-Plaq commented 2 weeks ago

Is your request related to a problem? Please describe. Multiline strings are rarely used (mostly for long texts that should be printed) and as such are not very useful. Keeping them would raise issues with indentation such as in python:

string = """My
    multiline
    string"""

This would print the indentation as well as the actual content, which is not wanted in this situation. This gets way more complex as the indentation level increases. It could be fixed by automatically removing all indents before each line up to the current indent level + 1. The issue with this would be the different styles of indentation, such as tabs, 2 spaces, 4 spaces or 8 spaces. Also, multiline string create errors with the planed multithreaded lexer (spoiler).

Describe the solution you'd like Remove all instances of multiline strings and their lexer implementation.

Describe alternatives you've considered Keep the multiline strings and remove all spaces that are a multiple of the indent level. The indentation type could be detected by checking the rest of the document, but this would raise issues with poorly indented files. There was a decision made by me and the rest of the core team to not make indentation necessary which means that any indentation should be allowed, which would make it even harder to handle than it already is.

Additional context For anyone wondering what I'm referring to, here is an example:

def my_function():
    if True:
        if True:
            try:
                string = """A
                             B
                             C"""
            except:
                pass
    return string

This will return

A
                             B
                             C

Which is probably not what the programmer intended.

create-issue-branch[bot] commented 2 weeks ago

Branch issue-136 created!

ElBe-Plaq commented 2 weeks ago

Well, this is awkward... Multiline strings were never implemented, but I've just found out that they crash the lexer. This will be fixed in another issue.