Ticket #201 (closed enhancement: fixed)

Opened 9 years ago

Last modified 5 years ago

Add Cobra support for namespace aliasing/Masking

Reported by: hopscc Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:


C# allows dismabiguation of colliding namespaces or aliasing a complex namespace name to something simpler with syntax on its using statement
Cobra should provide a similar capability for similar purposes
Namespace with own version of type Console ambiguous with System.Console.

using Console = Wrapper.Console;

See  Discussion Topic


use-aliases.patch Download (8.0 KB) - added by hopscc 8 years ago.

Change History

Changed 8 years ago by hopscc

Changed 8 years ago by hopscc

  • owner set to Chuck
  • status changed from new to assigned

Patch for both namespace and class in Namespaces aliasing.
Cleanup duplicated code in bindUsePhase
Additional tests.

Changed 7 years ago by Charles


Changed 5 years ago by Charles


Changed 5 years ago by Charles

This ticket mentions the C# syntax of:

using NewName = Existing.Name.Space;

The patch syntax is:

use Existing.Name.Space as NewName

Right now "as" is used for typing as in "x as List<of String>" or "i as int".

And "=" is used for assignment of values such as "i = 5".

All things considered, I think the "=" syntax is more appropriate than "as" because we are "assigning a name" rather than "declaring a type". Example:

use System.Web
use MyCompany.MyProject.Common
use Media = SomeProject.Foo.Media

Changed 5 years ago by hopscc

re 'as'
1) used for typing only in a variable dcl - 'use' isnt a variable dcl
2) We are declaring an alias for a namespace (name) - the namespace can be construed as a type (envelope)
and (more importantly)
'as' reads/parses clearer than 'equals' when reading it
(i.e. what its doing rather than what it (may) resemble)

use Nspace.X as nameY
use Nspace.X equals nameY

to be congruent with an assignment you'd want to reverse the order

use nameY equals Nspace.X
use nameY = Nspace.X

But its not an assignment and the alias name isn't a variable

(in the patch CobraParser line 507 'AS' -> 'EQUALS')

Changed 5 years ago by Charles

On the way.

Changed 5 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed


I went with the original assignment based syntax.


Note: See TracTickets for help on using tickets.