This is known by many different names - and probably called even more. And sometimes what you think is type aliasing in one language is something completely different in another.
In Perl, you've got code that looks like:
#!/usr/bin/perl
package Foo::Bar::Qux::Bletch;
$var = 42;
package main;
print $Foo::Bar::Qux::Bletch::var, "\n";
*A = *Foo::Bar::Qux::Bletch::var;
print $A,"\n";
Which is known by various things such as a typeglob alias or just glob aliasing - though it should be realized that a glob is something else.
In Clojure, this is simply an alias:
user=> (require 'clojure.string)
nil
user=> (alias 'string 'clojure.string)
nil
user=> (string/capitalize "hONdURas")
"Honduras"
In Ruby it appears to have the name of namespace alias as described in ruby-forum: Namespaces too looooooong
However it occurred to me that there is a difference between
namespace aliases in PHP and the closest thing in Ruby (as
described above): Autoloading.
In php, this is again, a namespace alias - php.net: Using namespaces: Aliasing/Importing
The ability to refer to an external fully qualified name with an alias, or importing, is an important feature of namespaces. This is similar to the ability of unix-based filesystems to create symbolic links to a file or to a directory.
PHP namespaces support three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, and aliasing a namespace name. Note that importing a function or constant is not supported.
In Lisp, this isn't part of the standard language but there libraries which do it and call themselves 'package-local alias' or 'nicknames'. One such library is cl-package-aliases which provides some additional functionality:
* (defpackage :foo (:use :cl) (:alias (:common-lisp :bar)))
# <PACKAGE "FOO">
* (in-package :foo)
# <PACKAGE "FOO">
* (bar:format t "Hello World~%")
Hello World
NIL
In python, this is a namespace alias. (Examples from Can you define aliases for imported modules in Python?)
import a_ridiculously_long_module_name as short_name
Though you can also do it with an assigment
import long_module_name
lmn = long_module_name
In C# this is a namespace alias.
From Java equivalent to C# using alias
namespace TheirNamespace
{
public class ContestedClassName
{
}
}
namespace MyNamespace
{
public class ContestedClassName
{
}
}
namespace MyBoundaryNamespace
{
using MyRenamedClass = MyNamespace.ContestedClassName;
using TheirRenamedClass = TheirNamespace.ContestedClassName;
public class Translator
{
public TheirRenamedClass Translate(MyRenamedClass value)
{
return null;
}
}
}
In Java, one doesn't alias a namespace, but rather imports specific items into the current namespace, though it does serve the question asked (how to reduce the amount of typing):
The code
double r = cos(Math.PI * theta);
can be reduced with a static import to:
import static java.lang.Math.PI;
...
double r = cos(PI * theta);
One often sees this usage with Junit to avoid having to specify each static method.
import static org.junit.Assert.*;
When people speak of type aliasing in Java it is more along the lines of:
A problem I often encounter in Java is that I want to say “these two
things are the same”, but Java won’t let me. Suppose I want to
maintain an int[] array which is always sorted in my program.
which gets to more of the type aliasing rather than namespace aliasing, because these are different things.
Type aliasing in Scala appears to be something quite different based on Beginner: Scala type alias in Scala 2.10? and Scala type alias including companion object
More about what type aliasing in Scala is can be found at Effective Scala
In C++11 type aliases are a type of typedef
which does more things other than namespace juggling.
using identifier = type_name;
An example of this would be:
// type alias, identical to
// typedef void (*func)(int, int);
using func = void (*) (int,int);
// the name 'func' now denotes a pointer to function:
void example(int, int) {}
func fn = example;
Though realize, there are some differences between these concepts as descried in Difference between typedef and C++11 type alias
The playing of namespaces however, is a namespace alias as described in In C++, what is a "namespace alias"?
namespace ublas = boost::numeric::ublas;
ublas::vector<double> v;
More on this at msdn namespace Alias
namespace a_very_long_namespace_name { ... }
namespace AVLNN = a_very_long_namespace_name;
// AVLNN is now a namespace-alias for a_very_long_namespace_name.
http://hyperpolyglot.org/ml shows a few languages with various forms of namespace aliasing.
OCaml:
module Gr = Graphics;;
Haskell:
import qualified Data.Bytestring as B
Namespaces aren't unique to programming languages, but also extend to other structured data such as XSL which has namespace aliases. These tend to be rather terse transformations (converting 'alt' to 'xsl' or something like that - but they serve the same purpose.
So, as noted, these concepts go by different names in different languages and what is known as 'type aliasing' in one language may mean something completely different in another language.
There is no standard name