Ron
Fri Jul 25 11:49:33 CDT 2003
Jon,
Aha, semantics! Perhaps I misunderstod the OP's original intention, but is
it totally wrong to interpret that "take an IConvertible reference" means
casting? If so, then clearly my answer is not valid ;-(. (It also means then
that I have misunderstod "Wouldn't that strengthen the function's contract"
to imply the contract between programmer and code, but not the contract
between code and compiler. Still thinking too much C like, where you were
heavily depend also on the contract between programmer and code. How creat
the C# is indeed ;-).
But it still remains open why it's implemented as object instead of
IConvertible. Yes, if its IConvertible, then it will "improve compile-time
safety", but why implemented as object? Perhaps it's finally time for me to
download the SSCLI and study that more carefully.
Ron
"Jon Skeet" <skeet@pobox.com> wrote in message
news:MPG.198b79d63503a0b398a20c@news.microsoft.com...
> Ron Bullman <ron.bulman@mail.com> wrote:
> > Please don't change the context.
>
> I really don't think I did.
>
> OP was spekulating
> > > > > > > Isn't this odd? Why doesn't the function take an IConvertible
> > > > > > > reference? Wouldn't that strengthen the function's contract as
> > this
> > casting to IConvertible would increase code bloat. (Which might be a
problem
> > or not).
>
> Your quoting here is unclear - the "casting to IConvertible" was not
> part of the OP's post, and is usually only necessary simply *because*
> the method signature specifies Object instead of IConvertible.
>
> > Any other toughts related to the OP's question?
>
> My post *did* relate to the OP's question, and to your answer. Here are
> my thoughts again:
>
> o Yes, it would be better if the method took an IConvertible argument
> instead of an Object argument. It would improve compile-time safety.
>
> o No, I don't accept the argument that it would increase code bloat, as
> only very rarely would casting be necessary: for the majority of cases,
> the caller's reference type is known to implement IConvertible, so
> there'd be no need to cast at all.
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too