This class is part of the VarProp example. Now what is very odd is that you can have side effects within the property setter:

procedure TMylntegerClass.SetNumber(var Value: Integer); begi n

100 This is the name Delphi R&D team member Chris Bensen gave to this feature it its blog post introducing the topic:

http: / / chrisbensen.blogspot.com/ 2008/04/ delphi-put-by-ref-properties.html

The other very unusual effect is that you cannot assign a constant value to the property, only a variable (which should be expected, as with any call involving a parameter passed by reference): var mc: TMyIntegerClass; begi n mc.Count := l0; // Error: E2036 Variable required mc.Number := n;

Again, this feature was introduced for COM support, and you'll see it at the beginning of type library files. Oddly enough if you define a "put by ref" property of string type, you can pass a string variable to it... but the compiler also lets you assign a string constant, which will cause an error at runtime. This is demonstrated in the VarProp example.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment