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’ »
Archive for February 2014
Quick, what should this routine produce?
expr := 'Value';
expr := expr = 5;
result := expr;
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’ »