Zig: Proposal: async prefix syntax

Created on 8 Aug 2019  路  3Comments  路  Source: ziglang/zig

The syntax specifies async<PrefixExpr> which is valid and non-ambiguous.

The problem is that it undermines parsing optimisations on expressions by terminating with a symbol that is also a legal infix operator (greater than). If you have seen c++ templates you understand the pain of parsing >.

Parsing strictly according to the grammar specification requires deep recursion on the most common constructs. This recursion/nesting can be optimised away but not if symbols are overloaded in this way.

I propose to use async(PrefixExpr) instead.

This is also consistent with how other function modifiers are used, e.g. align(8), linksection(".text")

Most helpful comment

If the allocator disappears then this proposal becomes obsolete.

All 3 comments

The allocator is being removed from async very very soon. See the rewrite-coroutines branch.

If the allocator disappears then this proposal becomes obsolete.

I opened the draft PR #3033 so that it's more visible

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewrk picture andrewrk  路  3Comments

andrewrk picture andrewrk  路  3Comments

dbandstra picture dbandstra  路  3Comments

komuw picture komuw  路  3Comments

andrewrk picture andrewrk  路  3Comments