By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,636 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,636 IT Pros & Developers. It's quick & easy.

event-declaration vs interface-event-declaration

P: n/a
Why interface-event-declaration does not support multiple declarators like
event-declaration?

Grammar from C# spec:

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

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

event-declaration:
[attributes] [event-modifiers] "event" type variable-declarators ";"

interface-event-declaration:
[attributes] ["new"] "event" type identifier ";"

For example grammar for interface-event-declaration may looks like this:

interface-variable-declarator:
interface-variable-declarator
interface-variable-declarator "," interface-variable-declarator

interface-variable-declarator:
identifier

interface-event-declaration:
[attributes] ["new"] "event" type interface-variable-declarators ";"

Alex.
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Alex Sedow" <al*******@mail.ru> wrote in message
news:OO**************@TK2MSFTNGP14.phx.gbl...
Why interface-event-declaration does not support multiple declarators like
event-declaration?

Grammar from C# spec:

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

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

event-declaration:
[attributes] [event-modifiers] "event" type variable-declarators ";"

interface-event-declaration:
[attributes] ["new"] "event" type identifier ";"

For example grammar for interface-event-declaration may looks like this:

interface-variable-declarator:
interface-variable-declarator
interface-variable-declarator "," interface-variable-declarator

interface-variable-declarator:
identifier

interface-event-declaration:
[attributes] ["new"] "event" type interface-variable-declarators ";"


I can't say for sure, but interfaces cannot define variables, only event
properties, unlike what happens in other types(which generates both an event
property and a local field). I would imagine it is done to maintain
consistency with other interface declarations.
Nov 16 '05 #2

P: n/a
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:ug**************@TK2MSFTNGP11.phx.gbl...

"Alex Sedow" <al*******@mail.ru> wrote in message
news:OO**************@TK2MSFTNGP14.phx.gbl...
Why interface-event-declaration does not support multiple declarators like event-declaration?

Grammar from C# spec:

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

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

event-declaration:
[attributes] [event-modifiers] "event" type variable-declarators ";"

interface-event-declaration:
[attributes] ["new"] "event" type identifier ";"

For example grammar for interface-event-declaration may looks like this:

interface-variable-declarator:
interface-variable-declarator
interface-variable-declarator "," interface-variable-declarator

interface-variable-declarator:
identifier

interface-event-declaration:
[attributes] ["new"] "event" type interface-variable-declarators ";"

I can't say for sure, but interfaces cannot define variables, only event
properties, unlike what happens in other types(which generates both an

event property and a local field). I would imagine it is done to maintain
consistency with other interface declarations.


Ok. Let's rename interface-variable-declarator with
interface-event-declarator:

interface-event-declarators:
interface-event-declarator
interface-event-declarator "," interface-event-declarator

interface-event-declarator:
identifier

interface-event-declaration:
[attributes] ["new"] "event" type interface-event-declarators ";"
C# examples:

class C
{
event EventType a, b;
// equal to
event EventType a;
event EventType b;
}

interface I
{
event EventType a, b; // syntax error
// equal to
event EventType a; // ok
event EventType b; // ok
}

Alex.
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.