[fpc-pascal] Object properties (note: object not class)

Neil Graham Lerc at screamingduck.com
Wed Aug 26 13:21:33 CEST 2009


Is the absence of properties on Objects an omission by design or simply
because no-one has gotten to it yet?

Similarly case statements as they appear in records are not supported.
I would quite like to have the functionality to do some sort of union on
a data structure that also supported (non-virtual) methods and
properties.

I completely understand any reluctance to incorporate the record based
case system into objects, it was not the best to begin with, but If the
same behaviour could be achieved by another means, it would make coding
some things a lot easier.

An example of the sort of thing where something like this would be
useful would be in the Matrix unit, which uses objects for both vectors
and matrices.

for example 

        Tvector2_single=object
            data:Tvector2_single_data;
            constructor init_zero;
            constructor init_one;
            constructor init(a,b:single);
            function length:single;
            function squared_length:single;
        end;

If Length were a property with a setlength method then it would make it
easy to do 
MyVector.Length:=1; 

instead of 
MyVector:=MyVector/MyVector.length;

Similarly many users of vectors would like to have X and Y available as
well as the data in array form.  





More information about the fpc-pascal mailing list