ECMA-334: event variable declarator

  • Thread starter Thread starter Alex Sedow
  • Start date Start date
A

Alex Sedow

Standart describe grammar for events as (in EBNF):

event-declaration:
[attributes] [event-modifiers] "event" type variable-declarators ";"
[attributes] [event-modifiers] "event" type member-name "{"
event-accessor-declarations "}"

variable-declarators:
variable-declarator
variable-declarators "," variable-declarator

variable-declarator:
identifier
identifier "=" variable-initializer

i.e. according this standart it is possible to use variable-initializer in
event declaration. But I not found any examples in standart or open source
projects where declarators was used.

Question: Is it possible to use declarators in event declaration?

Alex.
 
Yes, it certainly is. Its pretty rarely used, infact its one of those sneaky
little things that many people don't know about until they read the spec or
run across it.

this code shows its use:
 
Daniel O'Connell said:
Yes, it certainly is. Its pretty rarely used, infact its one of those
sneaky little things that many people don't know about until they read the
spec or run across it.

this code shows its use:

Hrmm, not entirely sure how I managed to send that. Anyway

This code shows the use of an event field initalizer:

using System;

public class Test
{
public static void HandlerMethod(object o, EventArgs e)
{
}
public event EventHandler Handler = new EventHandler(HandlerMethod);
}

The only suggested use I've seen for this is to apply a default handler to
events so you no longer have to check for null.
Alex Sedow said:
Standart describe grammar for events as (in EBNF):

event-declaration:
[attributes] [event-modifiers] "event" type variable-declarators ";"
[attributes] [event-modifiers] "event" type member-name "{"
event-accessor-declarations "}"

variable-declarators:
variable-declarator
variable-declarators "," variable-declarator

variable-declarator:
identifier
identifier "=" variable-initializer

i.e. according this standart it is possible to use variable-initializer
in
event declaration. But I not found any examples in standart or open
source
projects where declarators was used.

Question: Is it possible to use declarators in event declaration?

Alex.
 
Back
Top