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

[v2] Proposal - "rest of line" strings #402

Closed
zkat opened this issue Oct 10, 2024 · 5 comments
Closed

[v2] Proposal - "rest of line" strings #402

zkat opened this issue Oct 10, 2024 · 5 comments
Labels
breaking This can only be done for the next major version of KDL enhancement New feature or request

Comments

@zkat
Copy link
Member

zkat commented Oct 10, 2024

This was proposed by @imsnif a while back, and I don't think we gave it a proper discussion. I think there's a compelling argument to having "rest of line" raw strings.

So here's the idea, and feel free to lmk what you think!

A value that starts with #! will treat all following characters as literal string characters until the new Newline

That is, the the following two nodes are equivalent:

node1 foo=bar #!cargo run -- C:\foo\bar.exe # //foo
node2 foo=bar ##"cargo run -- C:\foo\bar.exe # //foo"##

Notice how we don't need multiple ## because the actual ending is the Newline, so having more # along the way doesn't matter.

I'm not like, super genki about this looking at them both side-by-side, but I think there's still some value in it for some very real use-cases (like zellij's cmd nodes!).

@zkat zkat added enhancement New feature or request breaking This can only be done for the next major version of KDL labels Oct 10, 2024
@IceDragon200
Copy link
Contributor

#! is typically shebang or hashbang, even if it's a document format, it could get confusing.

node1 foo=bar #>cargo run -- C:\foo\bar.exe # //foo
node2 foo=bar ##"cargo run -- C:\foo\bar.exe # //foo"##

I propose #> instead, > points right implying the user should look to the right for the end of the string

node {
  compile foo=bar #>mix compile
  release bar=foo #>mix release --overwrite
  run fizz=buzz {
    cmd #>/opt/app/bin/app run
    env {
      CONFIG_PATH #>/etc/app/config.kdl
    }
  }
}

@larsgw
Copy link
Contributor

larsgw commented Oct 11, 2024

IMO this might overcomplicate the format a bit. You could get the following file, which compiles but behaves unexpectedly.

node { foo #> bar; }
node #>bar {
  baz qux
}

is equivalent to

node {
  foo " bar; }"
  node "bar {"
  baz "qux"
}

@zkat
Copy link
Member Author

zkat commented Oct 12, 2024

Yeah that makes sense. I’m also not sure it would be worth adding a FOURTH string format to the language just for two characters worth of convenience

@zkat
Copy link
Member Author

zkat commented Oct 17, 2024

Because of the footgun that Lars mentioned, I'm going to close this one. I think typing two more characters ("#) isn't really worth optimizing any further, now that simple cases can be covered by identifier strings.

@zkat zkat closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
@tabatkins
Copy link
Contributor

Agreed, this matches with my own opinions on the matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This can only be done for the next major version of KDL enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants