473,554 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extern alias and dotted names

I'm playing with 2.0's extern alias declarations and the :: operator.
If I have an

extern alias My;

and the My namespace contains a TypeName, I can refer to My::TypeName
.... or to My.TypeName.

I don't quite get this latter usage: I can *not* refer to
global::My.Type Name nor can I refer to global.System.S tring.

Is My.TypeName an inconsistency, or did I just miss the msdn page that
explains it?

--
<http://www.midnightbea ch.com>
Jan 16 '06 #1
5 2426
Jon Shemitz <jo*@midnightbe ach.com> wrote:
I'm playing with 2.0's extern alias declarations and the :: operator.
If I have an

extern alias My;

and the My namespace contains a TypeName, I can refer to My::TypeName
... or to My.TypeName.

I don't quite get this latter usage: I can *not* refer to
global::My.Type Name nor can I refer to global.System.S tring.

Is My.TypeName an inconsistency, or did I just miss the msdn page that
explains it?


I'm not seeing the problem you are in a test program with other names.
Here's my code:

Lib.cs:
using System;

namespace Foo.Bar
{
public class Baz
{
public static void SayHi()
{
Console.WriteLi ne ("Hello alias");
}
}
}

Test.cs:
extern alias Lib;
using System;

namespace Foo.Bar
{
public class Baz
{
public static void SayHi()
{
Console.WriteLi ne ("Hello");
}
}
}

class Test
{
static void Main()
{
// Warning (unused variable), but don't worry about it
global::System. String foo = "hello";

Foo.Bar.Baz.Say Hi();
global::Foo.Bar .Baz.SayHi();
Lib::Foo.Bar.Ba z.SayHi();
}
}

Compile:
csc /target:library Lib.cs
csc Test.cs /r:Lib=lib.dll

Output:
Hello
Hello
Hello alias
It still works if I change "Foo" to "My" everywhere.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 16 '06 #2
"Jon Skeet [C# MVP]" wrote:
I'm not seeing the problem you are in a test program with other names.
Here's my code:
[Most of sample snipped]
global::System. String foo = "hello";
// But while you can NOT say
// global.System.S tring foo = "hello";
Lib::Foo.Bar.Ba z.SayHi();


// You CAN say
// Lib.Foo.Bar.Baz .SayHi();
// but not
// global::Lib.Foo .Bar.Baz.SayHi( );
What I really don't get is why I can say

Lib.Foo.Bar.Baz .SayHi();

as if the Lib alias were part of the global namespace - yet I can't
say

// global::Lib.Foo .Bar.Baz.SayHi( );
// it's NOT part of the global namespace

or

// global.Lib.Foo. Bar.Baz.SayHi() ;
// Why "Lib.Foo.Bar.Ba z.SayHi();" but not "global.System. string"?
--
<http://www.midnightbea ch.com>
Jan 16 '06 #3
Jon Shemitz <jo*@midnightbe ach.com> wrote:
"Jon Skeet [C# MVP]" wrote:
I'm not seeing the problem you are in a test program with other names.
Here's my code:


[Most of sample snipped]
global::System. String foo = "hello";


// But while you can NOT say
// global.System.S tring foo = "hello";


No - because global isn't a namespace, it's an alias.
Lib::Foo.Bar.Ba z.SayHi();


// You CAN say
// Lib.Foo.Bar.Baz .SayHi();


Eek - that surprises me. That surprises me a *lot*. I suspect it's a
bug in the compiler, but I'll have to check the specs.

<snip>

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 17 '06 #4
"Jon Skeet [C# MVP]" wrote:
// You CAN say
// Lib.Foo.Bar.Baz .SayHi();


Eek - that surprises me. That surprises me a *lot*. I suspect it's a
bug in the compiler, but I'll have to check the specs.


That'd be cool. What would you check? Aliases and the :: operator are
not in my printed copy of "The C# Programing Language" nor are they in
the online Word doc.

Would the [Lovely. Clear. Not!] ECMA spec be the place to go?

--
<http://www.midnightbea ch.com>
Jan 17 '06 #5
Jon Shemitz <jo*@midnightbe ach.com> wrote:
"Jon Skeet [C# MVP]" wrote:
// You CAN say
// Lib.Foo.Bar.Baz .SayHi();


Eek - that surprises me. That surprises me a *lot*. I suspect it's a
bug in the compiler, but I'll have to check the specs.


That'd be cool. What would you check? Aliases and the :: operator are
not in my printed copy of "The C# Programing Language" nor are they in
the online Word doc.

Would the [Lovely. Clear. Not!] ECMA spec be the place to go?


Yup, the ECMA spec it is. It's still in draft form. It's not *hugely*
easy to read, but it's not bad when you get into it.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8245
by: Bill Kratzer | last post by:
Hi... I am currently working on a Java-based product that is backed by PostgreSQL (among other databases). I have noticed that PostgreSQL appears to truncate column alias names after 31 characters. I have replicated this through JDBC (in Java), PEAR (in PHP), and on the command-line interface (psql). For example (this is from the...
3
6027
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. I run the following query with aliased columns with CLI: select table1.c1 as 'pet category', table1.c2 as 'item', table1.c3 as 'quantity',...
14
47870
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The SQL is pretty straightforward. I am updating a field with a Max effective dated row criteria. (PepopleSoft app) update PS_JOB as A set BAS_GROUP_ID...
5
9641
by: Santiago Ordax Solivellas | last post by:
Hi. We have almost all our tables defined on library lib1 and some on lib2. We have alias defined on lib1 to access tables on lib2 so there is no need to qualify library name. Alias for tables on lib2 are defined this way: CREATE ALIAS lib1.table1 FOR lib2.table1; Both table owner and alias owner is the same. Tables reside on a AS/400...
5
2845
by: Christian Christmann | last post by:
Hi, I've tree questions on the storage class specifier "extern": 1) Code example: int main( void ) { int b = -2; // my line 3 if ( a ) {
0
1322
by: Hervé | last post by:
I am referencing two different assemblies from a Visual Studio 2005 Web project. These two assemblies have the exact same type name defined (fully qualified name). This gives me a compilation error. To Solve this, I understand that I must use the 'extern alias' feature of C# 2.0 But where do I specify the alias for those assemblies?
2
1841
by: Daniel.Peaper | last post by:
Hi folks, I'm trying to write a simple SELECT statement that will execute in query analyser but will just have the data with no column names, or the dotted line between them and the data. I also want to avoid the statement at the end which says nnn rows affected. any ideas? I want to do this because I intend to write the results to a flat...
5
1816
by: Steven T. Hatton | last post by:
This note appears in the discussion of name hiding and uniqueness: §3.3 #4 This note is item #6 in the discussion of "Point of declaration" §3.3.1 #6 What exactly do these statements mean? "laborated-type-specifiers and friend declarations may introduce a
2
7332
by: Brian Kendig | last post by:
I'm trying to make a web page with a restaurant menu on it. Each line on the menu is the name of a dish (left-justified) and that dish's price (right-justified), with a dotted line between them. I'm doing something similar to this menu: http://cunardrestaurant.com/images/menu6.jpg But three things make it difficult: (1) the names of the...
0
7611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7812
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7574
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7894
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5162
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3579
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.