Re: Implicit overloads, non static



Jon Skeet [C# MVP] <skeet@xxxxxxxxx> wrote in
news:MPG.1ce5ad9686c4495098c0a4@xxxxxxxxxxxxxxxxxxxx:
> Sure, and I can see the use occasionally - but I don't think *most*
> devs need to overload operators.

No, they dont. But most developers dont build component sets - but Im sure
glad they are there for the developers of the FCL to make the FCL easier
for us to use - and for developers like myself who build FCL like libraries
that others (And myself) use.

> I didn't say they were useless, but I would certainly take issue with
> your claim that they're a "*very* important" feature of C#.

They are - becuase the FCL is written in C#. And since we use the FCL -
that makes it important. Without such, the FCL would not be as nice as it
is for us to use, and C# would be like the old VB. A class USING language,
but not a good class building language.

> Going back to your original question, however, the ability to set only
> part of a value on assignment is something which I believe would
> *always* be better done with a property or method.

Quite possibly - I didnt dispute that. I just wanted to verify that my
findings were correct in that it didnt exist.

> Just how often is often? As I say, I can't remember the last time I
> wrote such a bug - and come to think of it, I can't remember the last
> time I saw one in a colleague's code either.

I work with a lot of teams - and I see it fairly enough to know its a
roach. Ive also seen the most experienced C++ developers make this mistake
too.

> Personally I find while loops take much longer to check for that kind
> of error.

Not simple indexers.

for (int i = 1; i <= 5; i++)
Console.WriteLine(i);
}

for (int i = 1 to 5)
Console.WriteLine(i);
}

Only a diehard C++ developer (Which most are) would say the first one is
simpler to understand. I dont dispute its more expandable, but 99% of the
time thats never needed.

> Sure - so they're very rarely useful. They may be very useful to a very
> few people, but I think that comes under "very rarely useful on a user
> basis".

DIRECTLY maybe. But you USE the FCL. So indirectly they are VERY useful.

>> Quite possibly. It fully depends how its implemented.
>
> No, it's a bad idea on principle, IMO.

If its a bad idea - then so are the implicit convertors.

> And that's exactly what I'd *always* expect. If I tell a variable to
> have a new value, it had better *have* a new value afterwards. That's
> what I expect. It's a simple rule - why try to break it and confuse
> people?

It DOES have a new value- but its a value type - in fact its not even a
"value", it just mimics a value. But again - see above, Im not disputing
that default properties would be a good thing. My point of disagreement
with your statements regards existing behaviour in C# that you find little
use for and thus label as unimportant.

> Not sure what copy constructor behaviour you mean - could you
> elaborate?

Copy constructor is what implicit conversions cause.

BCD = 4;

This actually causes a new BCD instance to be created, and 4 is passed to
it.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
.



Relevant Pages

  • Re: Just PHP will give you nothing unless you upgrade yourself
    ... Sometime developers thinks that learning Only PHP ... Dont learn the CSS from book, ... MySQL becomes very popular by last couple of years becoz of it's ... What people should be learning is the general concepts of programming, ...
    (comp.lang.php)
  • Just PHP will give you nothing unless you upgrade yourself
    ... Sometime developers thinks that learning Only PHP ... Dont learn the CSS from book, ... Zend Framework (dont mix framework with the MVC concept.. ...
    (comp.lang.php)
  • Just PHP will give you nothing unless you upgrade yourself
    ... Sometime developers thinks that learning Only PHP ... Dont learn the CSS from book, ... Zend Framework (dont mix framework with the MVC concept.. ...
    (php.general)
  • Re: Implicit overloads, non static
    ... But most developers dont build component sets - but Im sure ... > glad they are there for the developers of the FCL to make the FCL easier ... I dont dispute its more expandable, ... > Copy constructor is what implicit conversions cause. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C++ in user mode dll
    ... " Microsoft recommends that developers use the .NET Framework rather than ... I dont understand how COM or .Net help me in place of my C++ class. ... Maxim Shatskih, Windows DDK MVP ...
    (microsoft.public.development.device.drivers)