General rule when not to write ;

H. S. Teoh hsteoh at quickfur.ath.cx
Wed May 19 18:06:16 UTC 2021


On Wed, May 19, 2021 at 05:53:12PM +0000, Alain De Vos via Digitalmars-d-learn wrote:
> It seems I need }; for a function a delegate and an alias.
> ```
> double function(int) F = function double(int x) {return x/10.0;};
> double delegate(int)   D = delegate double(int x) {return c*x/10.0;};
> alias myfunx=function int(int number) { return number; };
> ```

The ';' here is for terminating the alias, it is not part of the
delegate.

Basically, the grammar is this:

	alias SYMBOL = DEFINITION ;

It just so happens that DEFINITION here is a function literal:

	delegate ReturnType(...) { ... }

If you substitute this into the grammar, you get:

	alias SYMBOL = delegate ReturnType(...) { ... } ;

That's all there is to it.  This isn't rocket science.


T

-- 
Don't drink and derive. Alcohol and algebra don't mix.


More information about the Digitalmars-d-learn mailing list