On 26/02/2013 15:39, ListMember wrote: > On 2013-02-26 17:18, Sven Barth wrote: [...] >> It would be no use anyway. You CAN NOT have the record used as a field >> inside itself, so you'd need to define a pointer type anyway. And this is >> something where we won't do things behind the programmers back. If you need >> a pointer then you declare one. > > Well.. yes and no. > > Here is my use-case: > > I am working (on and off) on string classes. I have basically 3 string types: > TByteString, TWordString, TCardinalString string each representing a > different char/codepage width/bytesize. > > And, I'd like to have the user-facing interface to be somethig like this: > > TByteString = record > {...} > public > property AsWordString: TWordString read GetWordString write SetWordString; > property AsCardinalString: TCardinalString read GetCardinalString write > SetCardinalString; > end; > > TWordString = record > {...} > public > property AsByteString: TByteString read GetByteString write SetByteString; > property AsCardinalString: TCardinalString read GetCardinalString write > SetCardinalString; > end; > > TCardinalString = record > {...} > public > property AsByteString: TByteString read GetByteString write SetByteString; > property AsWordString: TWordString read GetWordString write SetWordString; > end; > > Having these properties would be very useful; but if I have to use pointers, > then I believe it would force almost all the rest of the calling code to be > based on pointers --defeating the purpose of simplicity for the user. >
Would it not do to have classes here (s/record/class) and [Set|Get][Byte|Word|Cardinal]String be class procedure; //'s and/or class function; //'s instead ? L. -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus