I suggest we ...

Aliases for namespaces

[ Edited by admin to apply to namespaces only, since as per comment you can already do this with module aliases ]

When using the ‘open’ keyword, allow a namespace being imported, to be assigned to an alias rather than the imported contents being made available to the current scope e.g.

namespace Foo = Some.Long.Path.To.Foo

This would be useful when importing namespaces containing modules/types with the same name to avoid fully qualifying all of the usages.

17 votes
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
Daniel Bradley shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...
  • Don Syme commented  ·   ·  Flag as inappropriate

    My feeling is that we will not do this feature. You can already alias types and modules so can define alternative names for those inn ambiguous cases. You can also use "global.Namespace1.Namespace2....." to disambiguate things. My feeling is that is sufficient in F# and also results in a good balance between code readability and aliasing.

  • Don Syme commented  ·   ·  Flag as inappropriate

    I edited the content to apply to namespaces only, since module aliases are already available.

  • Loic Denuziere commented  ·   ·  Flag as inappropriate

    You can already do:

    module Foo = Some.Long.Path.To.Foo

    Unfortunately you can't do that with namespaces, that would indeed be useful.

F# Language

Feedback and Knowledge Base