Predefined extensions
Freya will have to implement something like C# 3.0's extension methods. I'm not an extension method's fan, and some details still wait for a decision. Meanwhile, we have added some predefined extension methods to the predefined double type, so you can write this:
property Length: Double;
begin
Result := (x.Sqr + y.Sqr + z.Sqr).Sqrt;
end;
Every method defined in the static System.Math class can be used as an instance method on any System.Double instance. On the other hand, there's no Math.Sqr method at all: it's just an intrinsic method, requiring some compiler magic. Another "intrinsic" method extension: the Ord method applied to a Char expression.
Another addition to the compiler: a "peephole" optimizer. This is an optimizer that works on a IL representation. Right now, the optimizer choose between short and long branch codes, eliminates jumps in cascade, remove some useless data writes (most of them induced by the Result variable) and detects unreachable code.
Labels: optimization
0 Comments:
Post a Comment
<< Home