Namespace aliases notation, why the difference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Why do the 2.0 namespace aliases use the "::" notation where before the
namespaces used dot notation ".".

Ie.,

using IO = System.IO;

IO::Blah.Blah()..

instead of...

IO.Blah.Blah()...


Why why why the differnce?
 
IO::Blah.Blah()..

instead of...

IO.Blah.Blah()...

I sure hope that's optional. Are there any other C++ conventions being
foisted upon us in 2.0?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
I noticed it in the PDC powerpoint presentation TLS320_Hejlsberg.ppt

from microsoft.com/pdc homepage

I think its going to cause confusion if it is to be like this.
 
I think its going to cause confusion if it is to be like this.

As do I. The C# development team made a big todo about the simplicity of
scoping operators. I'd hate to see them backtrack on that if it yields
no material gain. Switching to '::' just because they can would be a bad
move.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
One of the problems that people ran into was that there was no way to say "I
mean this type, really!". If you wrote something like:

System.Console.WriteLine()

and you had something named "System" in scope, you had to resort to aliases,
which is unsightly. It's especially bad if you're generating code, as
there's no easy way to know when the situation might come up.

For 2.0, you can write:

global::System.Console.WriteLine()

and know that you're really dealing with System.Console.WriteLine.

We also allow you to define an alias for something else (like IO below), and
use it in a similar manner.

We expect that the use of these will be rare.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top