Re: [Lazarus] Helper for arrays

2016-10-02 Thread Aradeonas via Lazarus
> Maybe you can raise a discussion / feature request in the fpc-devel
> mailing list to include type helpers for generic arrays?

So we can have this feature for array it self and should use it for
generic arrays?

Regards,
Ara


-- 
http://www.fastmail.com - A no graphics, no pop-ups email service

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Maciej Izak via Lazarus
2016-10-02 16:20 GMT+02:00 Ondrej Pokorny via Lazarus <
lazarus@lists.lazarus-ide.org>:

> Maybe you can raise a discussion / feature request in the fpc-devel
> mailing list to include type helpers for generic arrays? :


This was discussed in Smart Pointers topic:

http://free-pascal-general.1045716.n5.nabble.com/Smart-Pointers-td5725159.html

-- 
Best regards,
Maciej Izak
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Ondrej Pokorny via Lazarus

On 02.10.2016 16:00, Aradeonas via Lazarus wrote:

I know I can make helper for array of integer


This is what I thought you want to.


but I want some helpers for all type of arrays.


Hmmm :( I don't know either.

Maybe you can raise a discussion / feature request in the fpc-devel 
mailing list to include type helpers for generic arrays? :


program Project1;

{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}

type
  generic TGenericArray = array of T;
  TIntArray = specialize TGenericArray;

  generic TGenericArrayHelper = type helper for TGenericArray
  public
  end;

begin
end.

If not added, you'll need to create a generic record wrapper:

program Project1;

{$mode objfpc}{$H+}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}

type
  generic TGenericArray = record
  private
FArray: array of T;
  public
function Count: Integer;
  end;

{ TGenericArray }

function TGenericArray.Count: Integer;
begin
  Result := Length(FArray);
end;

begin
end.


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Aradeonas via Lazarus
Ondrej can you point me to a sample?

I know I can make helper for array of integer but I want some helpers
for all type of arrays.

Regards,
Ara


-- 
http://www.fastmail.com - Faster than the air-speed velocity of an
  unladen european swallow

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Aradeonas via Lazarus
Thanks DougC I used it before but as I said before I want such helpers.

Thanks Maciej as always, I used NewPascal and I liked it but I want to
find out FPC is supporting it or not.

Regards,
Ara


-- 
http://www.fastmail.com - Send your email first class

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Ondrej Pokorny via Lazarus

On 02.10.2016 14:39, Aradeonas via Lazarus wrote:
Can I have or make helper for arrays? like making Count property so I 
can use it instead of Length ?


Yes, you can. FPC 3.0 supports it and Lazarus CodeTools support them as 
well.


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread Maciej Izak via Lazarus
2016-10-02 14:39 GMT+02:00 Aradeonas via Lazarus <
lazarus@lists.lazarus-ide.org>:

> Can I have or make helper for arrays? like making Count property so I can
> use it instead of Length ?


Try to use TDynArray dynamic array wrapper provided by mORMot framework.

http://synopse.info/files/html/Synopse%20mORMot%20Framework%20SAD%201.18.html#TITL_48

mORMot available out of box: http://newpascal.org


-- 
Best regards,
Maciej Izak
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Helper for arrays

2016-10-02 Thread DougC via Lazarus
I don't know the answer about helper function but I also dislike Length() for 
arrays.

I solve this dislike by using

  for i := Low(IntegerArray) to High(IntegerArray) do

which covers more possibilities because it handles lower index limit that is 
non-zero. 

Low() and High() also work with static arrays so you can use it almost 
everywhere.



Doug C.



 On Sun, 02 Oct 2016 08:39:51 -0400Aradeonas via Lazarus 
 wrote 




Hi,



Can I have or make helper for arrays? like making Count property so I can use 
it instead of Length ?

For example :



IntegerArray : array of integer;



for i:= to IntegerArray.Count -1 do





Regards,

Ara




-- http://www.fastmail.com - The professional email service 
--

___

Lazarus mailing list

Lazarus@lists.lazarus-ide.org

http://lists.lazarus-ide.org/listinfo/lazarus






-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus