Zig: Proposal: Allow comment(s) in multiline string literal

Created on 23 Oct 2020  路  2Comments  路  Source: ziglang/zig

I'm not sure of the feasibility but it would be nice if part of a multiline string could be commented out:

    pub fn get(self: *FormHandler, request: *web.Request,
               response: *web.Response) !void {
        try response.stream.writeAll(
            \\<form action="/form/" method="post" enctype="multipart/form-data">
            \\<input type="text" name="name" value="Your name"><br />
            // \\<input type="file" name="image"><br />
            \\<button type="submit">Submit</button>
            \\</form>
        );
    }

The comment seems to break it

$ zig build run
./src/main.zig:100:13: error: expected token ')', found 'MultilineStringLiteral'
            \\<button type="submit">Submit</button>
            ^
zhttpd...The following command exited with error code 1:
accepted proposal

All 2 comments

The stage2 parser accepts it, but stage1 doesn't right now

Landed in d9c36cb2506f1b8cb30c7e9e108c6005eea7cf66

Was this page helpful?
0 / 5 - 0 ratings