Methods Module
Functions and values
| Function or value |
Description
|
|
|
|
if false then x else y -> y (a branch of the conditional's own type only: a typed conditional keeps its type)
|
|
A fold that overflows here (decimal arithmetic is always checked) is left in the tree for the run time to throw.
|
|
|
|
not(false) -> true
(a plain bool constant only: Not on a Nullable
|
|
|
|
|
|
Purpose of this is to replace non-used anonymous types: new AnonymousObject(Item1 = x, Item2 = "").Item1 --> x The member's constructor argument is found through NewExpression.Members (the member at index i is initialised from argument i), for a tuple without Members through its ItemN, and for an anonymous type without Members by the name of the member the argument reads.
|
|
The later of two equal comparisons in one And'/Or' chain goes. Behind a short-circuit link (AndAlso, OrElse, a conditional) the right side runs only once the left side is true (false for Or'), so a comparison the left chain already holds is true (false) there. The earlier one stays, so nothing that was guarded by it runs ahead of it. Behind And/Or the right side runs regardless, and taking a comparison out of it would unguard what followed it there, so only a right side that is the comparison itself goes.
|
|
|
|
The purpose of this is to optimize away already known constant=constant style expressions. 7 > 8 --> False "G" = "G" --> True Only a comparison by value that returns bool: a built-in operator, and not the reference comparison of two objects (no Method on reference-typed operands).
|
|
Additional arithmetic identity optimizations x - 0 -> x, x - x -> 0, x % 1 -> 0
|
|
Simplify conditional expressions x ? true : false -> x, x ? false : true -> !x, x ? y : y -> y
|
|
String concatenation with empty string optimization "" + x -> x, x + "" -> x Only when x cannot be null: null + "" is "" (String.Concat), while x alone stays null, so `(x + "").Length` would go from 0 to a NullReferenceException.
|
|
|
|
|
|
|
|
|
|
Balance tree that is too much weighted to other side. The real advantage is not-so-nested-stack
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Factorize complementary disjunctions: (X && P) || (!X && P) -> P This handles the pattern where all states of a variable are covered
|
|
|
|
|
|
|