C# Async Functions

I was reviewing the new C# specification and the changes that Async Functions made to my beloved language and saw the below section. The outcome has two impression, First it’s funny! Seeing 5 identical phrase in a series in a programming language expression is strange and funny, admit it. But other than that it is definitely complex. It shows all the grammatical and lexical efforts behind the scene for developing such robust and non-nonsense language. Thank you guys, I love the way C# is growing. Thanks.

Syntax

The grammar of C# is extended as follows:

method-modifier:

asyncopt

lambda-expression:
asyncopt anonymous-function-signature => anonymous-function-body

anonymous-method-expression:
asyncopt delegate explicit-anonymous-function-signatureopt block

The async modifier is not allowed on method-declarations where the method-body is a ‘;’.

Note that async is a contextual keyword. In all syntactic contexts other than the ones above it is considered an identifier. Thus, the following is allowed (though strongly discouraged!):

using async = System.Threading.Tasks.Task;

async async async(async async) { }

Advertisements
%d bloggers like this: