attributes - Why aren't F# records allowed to have AllowNullLiteralAttribute? -
Is the reason for a compiler implementation that the record may not contain the AllowNullLiteralAttribute feature or is it a selected interrupt?
Sometimes I see this forceful cleaner code but not always.
[& lt; AllowNullLiteral Feature & gt;] Type IBTreeNode = {mutable left: IBTreeNode; Correct correct: IBTreeNode; Volatile Price: int} With this member. Example x = if x & lt; This.value again if it Left = zero then it Left and lieutenant; - {left = zero; Right = null; Value = x} and it's outside. Execute this x and x if it is. Right = Null it so Right & lt; - {left = null; Right = null; Value = x} and right.Insert x // If I have these public [& lt; AllowNullLiteralAttribute & gt;] If you want to type, there will be a lot more boilerplate. CBTreeNode (value) = Selective left = Falcon = Fixed let's variable value = value with member Inserts x = if x & lt; If left then left = zero left & lt; - Insert CBTreeNode (x) and left side. If right = the tap is fine & lt; - CBTreeNode (x) Other Correct. Indicator x
Variability has added an irreversible version to frown on the crowd. In this case it is about 30% faster.
type OBTree = | OBTree node * OBTree * int | Null with member Inreset x = match with this. | Node (left, right, value) when X & lt; = Price - & gt; Node (left.Instert X, right, value). Node (left, right, value) - & gt; Node (left, right x, value x). Null - & gt; Node (tap, faucet, x)
I can only make an estimate hazard, but the language is so It seems that there is something to avoid using null
(you can always use a option
if you need that functionality), and so its Use null
is actually something that should be limited to interop with other .NET languages. Therefore, F # specific types do not allow the use of null
.
Comments
Post a Comment