Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-24 Thread Виктор Матузенко via fpc-pascal
вт, 23 февр. 2021 г. в 23:45, Ryan Joseph via fpc-pascal < fpc-pascal@lists.freepascal.org>: > > Length(T) is what you want right? > Generic Length(T), yes. -- Victor Matuzenko (Виктор Матузенко) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-23 Thread Ryan Joseph via fpc-pascal
> On Feb 22, 2021, at 4:21 PM, Виктор Матузенко via fpc-pascal > wrote: > > Example of such an algorithm is binary search. I am able to access elements > with [] operator of both > arrays and objects, but I cannot get length in a generic way. > Length(T) is what you want right? Regards,

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-22 Thread Виктор Матузенко via fpc-pascal
пн, 22 февр. 2021 г. в 16:11, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > > Arrays are simply no structured types, > Actually they are... > thus them having "properties" is wrong as well. If users want expect > arrays to be object oriented they should use corresponding langu

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-22 Thread Graeme Geldenhuys via fpc-pascal
On 22/02/2021 1:10 pm, Sven Barth via fpc-pascal wrote: > If users > want expect arrays to be object oriented they should use corresponding > languages like Java or C#. Fully agree. Even Java doesn't "objectify" arrays as some type of object. Hence Java includes the Arrays class that has a static m

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-22 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mo., 22. Feb. 2021, 13:07: > > > > On Feb 21, 2021, at 2:59 PM, Sven Barth > wrote: > > > > You are supposed to use Length(X). There is no need for a "property". > One doesn't need to objectify each and everything! > > Yes but programmers tend to be neurotic

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-21 Thread Sven Barth via fpc-pascal
James Richters schrieb am Mo., 22. Feb. 2021, 01:07: > I've been using a lot of dynamic arrays of records lately, Some are even > Dynamic Arrays of records that contain other records, for example: > Type >XYZ_Record = Record > X,Y,Z : Double >End; > >Call_Stack_Record = Record

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-21 Thread Ryan Joseph via fpc-pascal
> On Feb 21, 2021, at 2:59 PM, Sven Barth wrote: > > You are supposed to use Length(X). There is no need for a "property". One > doesn't need to objectify each and everything! Yes but programmers tend to be neurotic and obsessive. :) I think many of us would appreciate a matching "Count" met

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-21 Thread James Richters via fpc-pascal
c-pascal] Generic routines for both dynamic array and other collections Am 21.02.2021 um 15:59 schrieb Ryan Joseph via fpc-pascal: > >> On Feb 20, 2021, at 7:52 PM, Виктор Матузенко via fpc-pascal >> wrote: >> >> And how do I write generic helper for all possibl

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-21 Thread Sven Barth via fpc-pascal
Am 21.02.2021 um 15:59 schrieb Ryan Joseph via fpc-pascal: On Feb 20, 2021, at 7:52 PM, Виктор Матузенко via fpc-pascal wrote: And how do I write generic helper for all possible dynamic arrays? By hand sadly. The RTL has added type helpers for many types but I don't think they added these f

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-21 Thread Ryan Joseph via fpc-pascal
> On Feb 20, 2021, at 7:52 PM, Виктор Матузенко via fpc-pascal > wrote: > > And how do I write generic helper for all possible dynamic arrays? By hand sadly. The RTL has added type helpers for many types but I don't think they added these for dynamic arrays. I agree that dynamic arrays shoul

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-20 Thread Виктор Матузенко via fpc-pascal
And how do I write generic helper for all possible dynamic arrays? вс, 21 февр. 2021 г. в 00:57, Ryan Joseph via fpc-pascal < fpc-pascal@lists.freepascal.org>: > > > > On Feb 20, 2021, at 5:19 AM, Виктор Матузенко via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > The helper needs

Re: [fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-20 Thread Ryan Joseph via fpc-pascal
> On Feb 20, 2021, at 5:19 AM, Виктор Матузенко via fpc-pascal > wrote: > > Hi, > > I am trying to write some generic routines for working with containers. For > example, GetLength function: > > > > unit u; > > {$MODE FPC} > {$MODESWITCH DEFAULTPARAMETERS} > {$MODESWITCH OUT} > {$MODESWI

[fpc-pascal] Generic routines for both dynamic array and other collections

2021-02-20 Thread Виктор Матузенко via fpc-pascal
Hi, I am trying to write some generic routines for working with containers. For example, GetLength function: unit u; {$MODE FPC} {$MODESWITCH DEFAULTPARAMETERS} {$MODESWITCH OUT} {$MODESWITCH RESULT} interface generic function GetLength(const V: TContainter): SizeUInt; implementation gener