WebSharper

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.

1
2
3
4
5
6
7
type Evnt =
    | START 
    | DONE

let x = Evnt.START
let y = Evnt.START
obj.ReferenceEquals(x,y) // f# = true, w# = false
  • JankoA

    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.
  • JankoA

    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

  • github

    This topic has been closed.