Mike Schilling <ms*************@hotmail.com> wrote:
These two fragments do not act identically:
<snip>
Indeed they don't.
I couldn't find any place this is documented.
No - it's not in the spec as far as I can see. Indeed, I'd go so far as
to say that the spec *implies* that they should do the same thing. From
section 15.9.5 (ECMA):
<quote>
A throw statement with an expression throws the value produced by
evaluating the expression. The expression must denote a value of the
class type System.Exception or of a class type that derives from
System.Exception. If evaluation of the expression produces null, a
System.NullReferenceException is thrown instead.
A throw statement with no expression can be used only in a catch block,
in which case, that statement re-throws the exception that is currently
being handled by that catch block.
</quote>
I suppose there's a difference between "re-throws" and "throws", but
it's a bit tricksy. I think it should at the very least suggest that
there *can* be a difference, and perhaps give an informational note
giving an example of what the difference is in the MS CLR.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too