ark-lang / ark

A compiled systems programming language written in Go using the LLVM framework
https://ark-lang.github.io/
MIT License
682 stars 47 forks source link

Multi line strings #692

Open felixangell opened 8 years ago

felixangell commented 8 years ago
vertex_shader: string = `
attribute vec3 vertex;
attribute vec3 normal;
attribute vec2 uv1;
attribute vec4 tangent;

uniform mat4 _mv;
uniform mat4 _mvProj;
uniform mat3 _norm;
uniform float _time;

varying vec2 uv;
varying vec3 n;

void main(void) {
    gl_Position = _mvProj * vec4(vertex, 1.0);
    uv = uv1;
    n = normalize(_norm * normal);
}
`;

The symbols for denoting a multi-line string are up for debate, though we're okay with `, and we also thought about allowing for matching pairs so:

```blah```
``blah``

And so on are valid.

MovingtoMars commented 8 years ago

These are raw strings (ie. escapes don't parse) right?

felixangell commented 8 years ago

@MovingtoMars Yep

MovingtoMars commented 8 years ago

What would be the use case for the matching pairs thing?

kiljacken commented 8 years ago

Typically when you wanted to use somewhere in the string. The problem that arises is however how to handle the situation where we want to have a as the last character. We also discussed to do a shell style:

a := <<END
stuff goes here
END
MovingtoMars commented 8 years ago

How about:

kiljacken commented 8 years ago

I'm not quite sure i get how that macro is supposed to work, did you accidentally something?

On Thu, 11 Feb 2016 04:12 Liam notifications@github.com wrote:

How about:

  • as raw strings
  • a macro source(asdf) for source code, eg:

— Reply to this email directly or view it on GitHub https://github.com/ark-lang/ark/issues/692#issuecomment-182681004.

felixangell commented 8 years ago

Yeah I don't really understand either

Acconut commented 8 years ago

Why is there a need to introduce a new syntax instead of allowing newlines in double-quoted strings?

For example:

shader: string = "
attribute vec3 vertex;
attribute vec3 normal;
…
";
kiljacken commented 8 years ago

We'd still (preferably) need a way to specify string where we can use symbols like " and \ without escaping them

MovingtoMars commented 8 years ago

A macro like this:

text := source!(`
func main() {
    a := "test";
    b := `hi`;
}
`);

Which expands to:

text := "\
func main() {\
    a := \"test\";\
    b := `hi`;\
}\
";