February 24, 2014, 12:22 pm
I’ve been working on the stub-building JIT for external routines in DWS lately, and I just checked in a bunch of updates. The JIT will currently handle parameters of most basic types, and return values of integer, enumerated, or object types. (Still working on the rest.) So it’s not complete yet, but it’s getting there. Continue reading ‘DWS Externals progress’ »
February 18, 2014, 8:37 pm
Quick, what should this routine produce?
[code lang="delphi"]
procedure Test;
var
expr: TExpression;
result: string;
begin
expr := 'Value';
expr := expr = 5;
result := expr;
writeln(result);
end;
[/code]
There are three basic answers here:
- Wait, you’re assigning a string to it, and then a boolean comparison against an integer… does that even compile?
- Well, first you’re assigning a string, then a boolean comparison against an integer, then turning it into a string… well, TExpression must be some sort of thing like a Variant. So the output should be “False”.
- If TExpression is a record, the output could be just about anything.
If you answered 3), you’re probably Stefan Glienke, or someone like him who already knows the trick. When I do this, the output is “(Value = 5)”. If you want to know how that’s possible in ordinary Delphi code, read on. Continue reading ‘Expression Trees: abusing operator overloading for fun and profit’ »