Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-01

Some property-wise inconvenience

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello,

Just noticed some difficulty in property's "array of something" support.

For example, if I've declared something like:

type
   T = class
   protected
     arr1: array of Double; (or ^Double);
   ...

I cannot use something like this:

   public
     property arr [i: LongInt]: Double read arr1;

Of course, I can use function instead, but that is not what I'm for. Firstly, accessing array this way will be much slower, and secondly, by declaring property in such a way I just wanted to warn user that this array is read-only (BTW, with single variables this works really nice).

Best regards,
Aleksey

Reply by email

Michael Van Canneyt
to Aleksey V. Vaneev
Aleksey V. Vaneev wrote 23 lines
Hello, Just noticed some difficulty in property's "array of something" support. For example, if I've declared something like: type T = class protected arr1: array of Double; (or ^Double); ... I cannot use something like this: public property arr [i: LongInt]: Double read arr1; Of course, I can use function instead, but that is not what I'm for. Firstly, accessing array this way will be much slower, and secondly, by declaring property in such a way I just wanted to warn user that this array is read-only (BTW, with single variables this works really nice).

1. As far as I know, Delphi also doesn't support this.
2. As declared above, there is no possibility of range checking. So this is dangerous.
3. AFAIK The function approach will not be much slower on new processors.

Michael.

Reply by email