In article <#f**************@tk2msftngp13.phx.gbl>, Michael Culley wrote:
"Dave Benjamin" <ra***@lackingtalent.com> wrote in message news:slrnbqljfn.b74.ra***@lackingtalent.com... How do you figure? If there are no listeners, it's not an error. It's just a
message with no recipients. This model forces the programmer to say "If
anyone's listening, then say this to everyone that's listening. Otherwise,
don't say anything". How is that different from saying "Say this to anyone
that's listening"? If a tree falls in the woods....
But that would mean creating an instance of each event delegate
for each object that is created.
Well, it's all how you look at things. I didn't understand the null behavior
very well, but I get it now (thanks to you and Daniel). But you could think
of an event as a specialized collection object that contains only delegates,
such that calling the collection as a function results in the delegates
getting called. Obviously, that's not what's really going on here, but it
would be an equally plausible solution to the multiple listener problem. In
that case, you would just add/remove delegates to these collections as
desired, and all events would be callable even if they were empty.
Anyway, thanks for the insight.
But it's okay to use += or -= on a Null reference? You're not making any
sense here...
Of course. += calls the static operator that takes two references as parameter and
returns a reference, so is perfectly acceptable to work on a null
reference... [snip]
Ahh, I hadn't realized that it worked that way. I guess that makes sense,
but it's definitely a surprise to me. For instance, the following cannot hold:
a.equals(b) <--> a == b
Because null.equals(b) would be invalid. (Not sure if that's valid
semantically in C# since I'm very new to the language).
--
..:[ dave benjamin (ramenboy) -:-
www.ramenfest.com -:-
www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :