prql icon indicating copy to clipboard operation
prql copied to clipboard

r-strings & comments

Open max-sixty opened this issue 4 years ago • 3 comments

I started implementing r-strings, partly for https://github.com/prql/prql/issues/376

But ofc one issue: our comments are #.

So

    fn test_r_string() {
        assert_yaml_snapshot!(parse(r###"
        derive x: r#"r-string test"#
        "###).unwrap(), @r###"
        ---
        version: ~
        dialect: Generic
        nodes:
          - Pipeline:
              - Derive:
                  - NamedExpr:
                      name: x
                      expr:
                        Ident: r
        "### )
    }

What do we think about the best syntax to use for comments? # is friendly and used for python (and BigQuery). But I'm not sure there are any intrinsic qualities which mean we need to keep it.

max-sixty avatar Apr 18 '22 17:04 max-sixty

I would say that there are two options: # and //. There is also -- from SQL and Haskel and ' from VB.NET, but they are non-conventional so I would avoid them.

# is used in Python and R, which overlap with our target audience a lot, so that would be a good choice. If we go with that, we cannot use r#" text "# for multiline strings. There is """ text """ from python, which is easier to use, but it has the constraint that you cannot use """ in text, i believe.

Only alterntive is changing comments //, which are more common, but less new-user friendly.

I'm for the python multiline strings.

aljazerzen avatar Apr 21 '22 09:04 aljazerzen

Yes, good point, and +1 re the target audience.

We could expand it to any number of ", either an odd number or >2, to get to full generality.

max-sixty avatar Apr 21 '22 17:04 max-sixty

I like the python strings too , and # for comments 👍

qorrect avatar Apr 22 '22 13:04 qorrect