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

Comments

Projects
None yet
1 participant
@Jand42
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

This comment has been minimized.

Show comment
Hide comment
@Jand42

Jand42 May 24, 2017

Member

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.
Member

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

This comment has been minimized.

Show comment
Hide comment
@Jand42

Jand42 May 26, 2017

Member

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

Member

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