views:

263

answers:

9

Twice this week, I've read people write that an event (.net) was "thrown". I've always thought that the verb to use with events is either "fire" or "raise". I thought that "thrown" was used for exceptions, but not events ("raise" can be used for either).

Does anyone else find it confusing for events to be "thrown"?

+18  A: 

I agree, events are raised/fired/triggered. If anything is thrown it's exceptions.

Antony Scott
I did think of saying tantrums and exceptions!
Antony Scott
Is it sick to say hamsters?
Xetius
+2  A: 

Raise is the verb that seems to be most common in the MSDN docs.

I agree - if I hear that something was thrown, I assume it's an exception. The C# language makes that one very explicit - throw is a reserved word used with exceptions.

Reed Copsey
A: 

You typically hear people refer to events being fired or raised. But thrown is perfectly fine in my opinion. The key is if they say the event was thrown.

Don't try and split to many hairs. Our profession is complicated enough with the thousands of technologies let alone thinking about the tiny nuances of how we communicate.

JoshBerke
+1 - As long as you're clear what the person means to say, then you shouldn't be concerned.
Jason Baker
+5  A: 

One other term is "Invoked". Since events are delgates, they are Invoked to call them, but yes the general term is either "fired" or "raised".

Also, use of the word "throw" in this context is confusing, because it will be confused with the "throw" keyword. You can't throw an event with the throw keyword.

Mystere Man
+2  A: 

Although it's possible to throw things that aren't exceptions, it's quite clear that throw is only meant to be used with exceptions. Raise is indeed the term you'd use for signifying that an event has happened.

John Feminella
+2  A: 

No, they can't be thrown, but much like dwarves and hobbits, they can be tossed.

George Stocker
A: 

I'd say you publish an Event.

boutta
+5  A: 

The standard convention in the MSDN library seems to refer to Raising an Event and Throwing an Exception.

Rob
A: 

I think events can be thrown, but it's incompetent coding if you actually do.

Let me explain. In C++ you can throw any type. You can throw booleans. You can throw enum error_type. You can throw std::exception. And of course you can throw struct XEvent.

But you most likely are doing something either horribly wrong or horribly confusing (and thus wrong) if you actually do.

I'm all for not overloading the meanings of words, to avoid ambiguity (where it doesn't need to exist).

I think "throw" is commonly understood to imply call stack unwinding (for when you have a well-defined stack, but I think it can be extended to a singly linked list of unbounded in-degree; that is, a tree of parent pointers). Let's stick to that.

The word "raise" is used for signals as well. It'd be nice if it's possible to avoid using this for events too.

I prefer "fired" for when the event happens ("the onMouseOver event just fired"), and maybe "was signalled" when the event listener notifies the consumer ("the XMouseMotionNotify event was signalled to the client").

Jonas Kölker