Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating global aliases/Type abbreviations: using global Directive #2488

Closed
bugproof opened this issue May 6, 2019 · 3 comments
Closed

Creating global aliases/Type abbreviations: using global Directive #2488

bugproof opened this issue May 6, 2019 · 3 comments

Comments

@bugproof
Copy link

bugproof commented May 6, 2019

There's no suitable alternative for typedef from C++. My proposition is to add using global directive that will allow defining global aliases:

so instead of writing this:

public class MyAliasForGenericType : GenericType<object>
{
// constructors...
...
}

we could write this:

using global MyAliasForGenericType = GenericType<object>;
using global MyNumber = int;

(we could define this in file like Aliases.cs or just below the type we're creating an alias for)

The problem with the first approach is that we can't implicitly convert from GenericType<object> to MyAliasForGenericType.

Today aliases can be used but only in the scope of the file, they're defined in. With using global it would be available everywhere. It would be great when access modifier could be set for an alias e.g. internal, or some attribute that controls the visibility.

internal using global MyAliasForGenericType = GenericType<object>;

or

using global internal MyAliasForGenericType = GenericType<object>;

or maybe something like

internal MyAliasForGenericType = GenericType<object>;
internal MyNumber = int;

similar to how F# does it https://fsharpforfunandprofit.com/posts/type-abbreviations/

@bugproof bugproof changed the title using global Directive creating global aliases: using global Directive May 6, 2019
@bugproof bugproof changed the title creating global aliases: using global Directive Creating global aliases: using global Directive May 6, 2019
@bugproof bugproof changed the title Creating global aliases: using global Directive Creating global aliases/Type abbreviations: using global Directive May 6, 2019
@svick
Copy link
Contributor

svick commented May 6, 2019

This looks like a duplicate of #1170, #410 and #259.

@VBAndCs

This comment has been minimized.

@YairHalberstadt
Copy link
Contributor

Closing as duplicate of #1170, #410 and #259.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants