www.digitalmars.com         C & C++   DMDScript  

D - dmd 0.42 release

reply "Walter" <walter digitalmars.com> writes:
Implemented new alias declarations.

www.digitalmars.com/d/declaration.html

ftp://ftp.digitalmars.com/dmdalpha.zip
Sep 12 2002
parent reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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? =20

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:=20
	import string;

	alias string.strlen mylen;
	...
	int len =3D mylen("hello");	// actually calls string.strlen()
=09
The following alias declarations are valid:=20
	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
=09
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:=20
	version (Win32)
	{
	    alias win32.foo myfoo;
	}
	version (linux)
	{
	    alias linux.bar myfoo;
	}
=09
Note: Type aliases can sometimes look indistinguishable from alias =
declarations:=20
	alias foo.bar abc;	// is it a type or a symbol?
=09
The distinction is made in the semantic analysis pass.=20
-------------------------------------------------------------------------=
-------
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.
=20
 www.digitalmars.com/d/declaration.html
=20
 ftp://ftp.digitalmars.com/dmdalpha.zip
=20
=20
=20
=20
Sep 12 2002
parent "Walter" <walter digitalmars.com> writes:
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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? =20

  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:=20
	import string;

	alias string.strlen mylen;
	...
	int len =3D mylen("hello");	// actually calls string.strlen()
=09
  The following alias declarations are valid:=20
	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
=09
  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:=20
	version (Win32)
	{
	    alias win32.foo myfoo;
	}
	version (linux)
	{
	    alias linux.bar myfoo;
	}
=09
  Note: Type aliases can sometimes look indistinguishable from alias =
declarations:=20
	alias foo.bar abc;	// is it a type or a symbol?
=09
  The distinction is made in the semantic analysis pass.=20
-------------------------------------------------------------------------=
-----
  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.
  >=20
  > www.digitalmars.com/d/declaration.html
  >=20
  > ftp://ftp.digitalmars.com/dmdalpha.zip
  >=20
  >=20
  >=20
  >=20
Sep 13 2002