Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Multi line strings #692

Open
felixangell opened this issue Feb 10, 2016 · 10 comments
Open

Multi line strings #692

felixangell opened this issue Feb 10, 2016 · 10 comments
Labels
Milestone

Comments

@felixangell
Copy link
Member

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.

@felixangell felixangell added this to the bootstrap milestone Feb 10, 2016
@MovingtoMars
Copy link
Member

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

@felixangell
Copy link
Member Author

@MovingtoMars Yep

@MovingtoMars
Copy link
Member

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

@kiljacken
Copy link
Member

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
Copy link
Member

How about:

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

@kiljacken
Copy link
Member

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 [email protected] wrote:

How about:

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


Reply to this email directly or view it on GitHub
#692 (comment).

@felixangell
Copy link
Member Author

Yeah I don't really understand either

@Acconut
Copy link
Contributor

Acconut commented Feb 11, 2016

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
Copy link
Member

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

@MovingtoMars
Copy link
Member

A macro like this:

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

Which expands to:

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

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

No branches or pull requests

4 participants