Klaus Löffelmann said:
mySpecialObject is the one, you like other types being casted to.
Further provide Toxxx-Methods for your "Special"-Object, to cast them
back
Defeats the purpose unfortunately. It requires the user to interact
directly with the destination type.
But wouldn't you then create a "new old Visual Basic" behaviour, that you
don't like? I think, explicit casting does more for type safety than
implicit casting?!
No, because behaviour is well defined and among truly convertible types.
Formerly in VB you could do 2 + 2 + 1 and sometimes get 23 because of the
rules of conversion of data types when added / concatted. And the fact that
concat and add were the same symbol. | was only added later and they still
preverved +.
These conversions are well defined with rules about what can go where, and
do not create commonly abmigous circumstance. They also do not allow data
loss, or if they do they have strict rules about it and only at the
override of the user.
Im all too well acquainted with VB prior to .net.
I know I will offend some people - but VB *was* a horrible mess of a
language. VB.net finally fixed things - but unfortunately MS also seems to
have just tinkered in some spots too for no reason.
I started work in VB 1 for DOS, long before most of you probably ever heard
of VB. Prior to that in PDS which was VB's successor, at least in language.
I've worked very heavily in VB all the way up to 4 and did some work in 5
and 6 as well.
VB 3 was a decent language with some pitfalls. As a very active VB person
at the time and regular VB magazine contributor I was with the rest of the
community hopeful. But then MS totally let us down with 4.
VB4 was not only incredibly buggy (Curse of MS and version 4) but it was
abboration. They should have taken this opportunity to fix some of the
issues in VB3 as a langauge. Instead they did not fix them, but actually
took the language BACKWARDS.
I went Delphi as it came out at the same time. It had everything VB4 should
have had and more.
Its nice to see that VB.net has finally "Fixed" VB.
--
Chad Z. Hower (a.k.a. Kudzu) -
http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at
http://www.atozedsoftware.com