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

Singleton value for argumentless union cases #696

Closed
Jand42 opened this issue May 24, 2017 · 2 comments
Closed

Singleton value for argumentless union cases #696

Jand42 opened this issue May 24, 2017 · 2 comments

Comments

@Jand42
Copy link
Member

Jand42 commented May 24, 2017

Currently WS creates a new object on each union case construction, whereas in .NET argumentless union cases use a single static instance. This should follow .NET semantics closer for performance.

type Evnt =
    | START 
    | DONE

let x = Evnt.START
let y = Evnt.START
obj.ReferenceEquals(x,y) // f# = true, w# = false
@Jand42
Copy link
Member Author

Jand42 commented May 24, 2017

Optional:

  • Optimize equality/non-equality checks against an argumentless union value so that it just checks tag instead of getting instance value and calling generic comparer.

@Jand42
Copy link
Member Author

Jand42 commented May 26, 2017

A regression: unions with no prototype and a singleton case will have an Address on their metadata, to look up singleton values. Type checks against the union (for example using it in an erased union) will mistakenly think the address is also a valid prototype to check against, ignoring HasWsPrototype

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

1 participant