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

add overloading default operator #13321

Open
furesoft opened this issue Sep 13, 2016 · 7 comments
Open

add overloading default operator #13321

furesoft opened this issue Sep 13, 2016 · 7 comments

Comments

@furesoft
Copy link

please add a cutom operator to overload the default macro

@NN---
Copy link
Member

NN--- commented Sep 13, 2016

Can you elaborate ?

@furesoft
Copy link
Author

like when you have a custom valuetype. you might overload the default operator for example:

my value type is: Color
default overriding operator returns: Color.None

@NN---
Copy link
Member

NN--- commented Sep 13, 2016

Not sure I understand.
Can you provide some code sample?

@furesoft
Copy link
Author

struct Color {
R: byte;
G: byte;
B : byte;
A : byte;

macro default() { // here general operator overloadig
Color.Empty;
}
}

@NN---
Copy link
Member

NN--- commented Sep 16, 2016

What is the usage?

@furesoft
Copy link
Author

def empty = default(Color);

@NN---
Copy link
Member

NN--- commented Sep 18, 2016

I don't think it is a good idea here.
default for value types fills data with zero and this is .NET behavior.
You can introduce a different macro which does what you want.

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

2 participants