Thread overview
dmd 0.42 release
Sep 12, 2002
Walter
Sep 13, 2002
Sean L. Palmer
Sep 13, 2002
Walter
September 12, 2002
Implemented new alias declarations.

www.digitalmars.com/d/declaration.html

ftp://ftp.digitalmars.com/dmdalpha.zip




September 13, 2002
So I finally got my buggy email editor to work and was wondering if there has to be any particular ordering to the alias declarations that you can use within a scope?  How and when is the lookup done?  Does lexical order matter?

For that matter, does it matter about lexical order of local variable declarations?  I don't see why it should, except an initialization might be easily taken out of order in presence of prior assignments.

Sean

From the Digital Mars website:

Alias Declarations
A symbol can be declared as an alias of another symbol. For example:
	import string;

	alias string.strlen mylen;
	...
	int len = mylen("hello");	// actually calls string.strlen()

The following alias declarations are valid:
	template Foo2(T) { alias T t; }
	instance Foo2(int) t1;	// a TemplateAliasDeclaration
	alias instance Foo2(int).t t2;
	alias t1.t t3;
	alias t2 t4;
	alias instance Foo2(int) t5;

	t1.t v1;	// v1 is type int
	t2 v2;		// v2 is type int
	t3 v3;		// v3 is type int
	t4 v4;		// v4 is type int
	t5.t v5;	// v5 is type int

Aliased symbols are useful as a shorthand for a long qualified symbol name, or as a way to redirect references from one symbol to another:
	version (Win32)
	{
	    alias win32.foo myfoo;
	}
	version (linux)
	{
	    alias linux.bar myfoo;
	}

Note: Type aliases can sometimes look indistinguishable from alias declarations:
	alias foo.bar abc;	// is it a type or a symbol?

The distinction is made in the semantic analysis pass.
--------------------------------------------------------------------------------
Copyright (c) 1999-2002 by Digital Mars, All Rights Reserved

"Walter" <walter@digitalmars.com> wrote in message news:alr39k$2nk3$1@digitaldaemon.com...
> Implemented new alias declarations.
> 
> www.digitalmars.com/d/declaration.html
> 
> ftp://ftp.digitalmars.com/dmdalpha.zip
> 
> 
> 
> 


September 13, 2002
The ordering is lexical order, and the semantic processing is done in order just like for other variables. It does not work like templates, where semantic processing is delayed until instantiation.

Lexical order does matter in that locals must be defined before use. (This is not true for globals.)

  "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:als15i$ma7$1@digitaldaemon.com...
  So I finally got my buggy email editor to work and was wondering if there has to be any particular ordering to the alias declarations that you can use within a scope?  How and when is the lookup done?  Does lexical order matter?

  For that matter, does it matter about lexical order of local variable declarations?  I don't see why it should, except an initialization might be easily taken out of order in presence of prior assignments.

  Sean

  From the Digital Mars website:
  Alias Declarations
  A symbol can be declared as an alias of another symbol. For example:
	import string;

	alias string.strlen mylen;
	...
	int len = mylen("hello");	// actually calls string.strlen()

  The following alias declarations are valid:
	template Foo2(T) { alias T t; }
	instance Foo2(int) t1;	// a TemplateAliasDeclaration
	alias instance Foo2(int).t t2;
	alias t1.t t3;
	alias t2 t4;
	alias instance Foo2(int) t5;

	t1.t v1;	// v1 is type int
	t2 v2;		// v2 is type int
	t3 v3;		// v3 is type int
	t4 v4;		// v4 is type int
	t5.t v5;	// v5 is type int

  Aliased symbols are useful as a shorthand for a long qualified symbol name, or as a way to redirect references from one symbol to another:
	version (Win32)
	{
	    alias win32.foo myfoo;
	}
	version (linux)
	{
	    alias linux.bar myfoo;
	}

  Note: Type aliases can sometimes look indistinguishable from alias declarations:
	alias foo.bar abc;	// is it a type or a symbol?

  The distinction is made in the semantic analysis pass.
------------------------------------------------------------------------------
  Copyright (c) 1999-2002 by Digital Mars, All Rights Reserved

  "Walter" <walter@digitalmars.com> wrote in message news:alr39k$2nk3$1@digitaldaemon.com...
  > Implemented new alias declarations.
  >
  > www.digitalmars.com/d/declaration.html
  >
  > ftp://ftp.digitalmars.com/dmdalpha.zip
  >
  >
  >
  >