Re: [fpc-devel] Little feature teaser

2013-08-05 Thread Sven Barth
Am 06.08.2013 04:25 schrieb "Dmitry Boyarintsev" : > > Does a debugger understands that? As long as FPC outputs the correct debug information and the source of the unit where the generic is declared is available you can safely step into it. Just test it with Lazarus and a type based generic (it sh

Re: [fpc-devel] Little feature teaser

2013-08-05 Thread Dmitry Boyarintsev
Does a debugger understands that? On Friday, August 2, 2013, Sven Barth wrote: > Hello together! > > Just a little feature teaser what I'm currently working on when I find the > time. :) > > === source begin === > > program tgenfuncs; > > {$modeswitch result} > > generic function IsIn(aElement: T

Re: [fpc-devel] Little feature teaser

2013-08-04 Thread Florian Klämpfl
Am 04.08.2013 14:20, schrieb Sven Barth: >>> Jupp, it indeed works now. Now the compiler would "just" need to detect >>> that the for loop is basically only using constants and evaluate that at >>> compile time... but that's a wish for another day ;) >> >> I think item 635365 of my todo list, the a

Re: [fpc-devel] Little feature teaser

2013-08-04 Thread Sven Barth
On 04.08.2013 14:40, Paul Ishenin wrote: 04.08.13, 20:20, Sven Barth пишет: Then I just need to wait until you've done the 635364 other items on your list. Sounds doable :P This is not doable even if Florian will do 10 items per day. The life is not as long as we wish. You're aware that my

Re: [fpc-devel] Little feature teaser

2013-08-04 Thread Paul Ishenin
04.08.13, 20:20, Sven Barth пишет: Then I just need to wait until you've done the 635364 other items on your list. Sounds doable :P This is not doable even if Florian will do 10 items per day. The life is not as long as we wish. Best regards, Paul Ishenin ___

Re: [fpc-devel] Little feature teaser

2013-08-04 Thread Sven Barth
On 04.08.2013 10:46, Florian Klaempfl wrote: Am 03.08.2013 23:31, schrieb Sven Barth: On 03.08.2013 22:50, Florian Klämpfl wrote: Am 03.08.2013 17:19, schrieb Sven Barth: On 03.08.2013 13:12, Florian Klämpfl wrote: First, FPC does not loop unrolling by default, you need -Ooloopunroll, secon

Re: [fpc-devel] Little feature teaser

2013-08-04 Thread Florian Klaempfl
Am 03.08.2013 23:31, schrieb Sven Barth: On 03.08.2013 22:50, Florian Klämpfl wrote: Am 03.08.2013 17:19, schrieb Sven Barth: On 03.08.2013 13:12, Florian Klämpfl wrote: First, FPC does not loop unrolling by default, you need -Ooloopunroll, second, the loop is relatively long, so let the com

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
On 03.08.2013 22:50, Florian Klämpfl wrote: Am 03.08.2013 17:19, schrieb Sven Barth: On 03.08.2013 13:12, Florian Klämpfl wrote: First, FPC does not loop unrolling by default, you need -Ooloopunroll, second, the loop is relatively long, so let the compiler assume a long pipeline with - Cppent

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Florian Klämpfl
Am 03.08.2013 17:19, schrieb Sven Barth: > On 03.08.2013 13:12, Florian Klämpfl wrote: >> >>> First, FPC does not loop unrolling by default, you need -Ooloopunroll, >>> second, the loop is relatively long, so let the compiler assume a long >>> pipeline with - Cppentium4 >>> >> >> -Oopentium4 it is.

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
On 03.08.2013 13:12, Florian Klämpfl wrote: First, FPC does not loop unrolling by default, you need -Ooloopunroll, second, the loop is relatively long, so let the compiler assume a long pipeline with - Cppentium4 -Oopentium4 it is. Are you sure that you don't mean -Oppentium4? The compiler

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Florian Klämpfl
>First, FPC does not loop unrolling by default, you need -Ooloopunroll, >second, the loop is relatively long, so let the compiler assume a long >pipeline with - Cppentium4 > -Oopentium4 it is. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Florian Klämpfl
Sven Barth schrieb: >On 03.08.2013 09:36, Sven Barth wrote: >> Am 02.08.2013 23:26 schrieb "Florian Klämpfl" > >: >> > >> > Am 02.08.2013 17:46, schrieb Sven Barth: >> > > - using an array declared as a ranged array (array[0..2] of >> LongInt) the >> > > for-lo

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
On 03.08.2013 09:36, Sven Barth wrote: Am 02.08.2013 23:26 schrieb "Florian Klämpfl" mailto:flor...@freepascal.org>>: > > Am 02.08.2013 17:46, schrieb Sven Barth: > > - using an array declared as a ranged array (array[0..2] of LongInt) the > > for-loop is inlined and optimized a bit (especial

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
On 03.08.2013 12:17, Marco van de Voort wrote: In our previous episode, Sven Barth said: And the same (problem) in C++. Is there some proposal to mitigate the code duplication? Or the official position is that if the project is big enough to suffer from the bloat it should avoid itself the dupli

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Marco van de Voort
In our previous episode, Sven Barth said: > > And the same (problem) in C++. Is there some proposal to mitigate the > > code duplication? Or the official position is that if the project is > > big enough to suffer from the bloat it should avoid itself the > > duplicate declarations? > > The proble

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
Am 03.08.2013 09:43 schrieb "Jonas Maebe" : > > > On 03 Aug 2013, at 09:36, Sven Barth wrote: > > > And regarding that: open arrays can only be with a "const" and none > > modifier, right? > > No, they can be passed like any other parameter, including with "var" and "out". Ok, I wasn't aware of th

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Jonas Maebe
On 03 Aug 2013, at 09:36, Sven Barth wrote: > And regarding that: open arrays can only be with a "const" and none > modifier, right? No, they can be passed like any other parameter, including with "var" and "out". Jonas___ fpc-devel maillist - fpc-

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
Am 02.08.2013 23:26 schrieb "Florian Klämpfl" : > > Am 02.08.2013 17:46, schrieb Sven Barth: > > - using an array declared as a ranged array (array[0..2] of LongInt) the > > for-loop is inlined and optimized a bit (especially depending on the > > optimization settings), but the compiler does not ye

Re: [fpc-devel] Little feature teaser

2013-08-03 Thread Sven Barth
Am 03.08.2013 05:24 schrieb "Dennis Poon" : > > What about code size? >>> >>> >>> The code size for one unit is the same as if you had (in that example) >>> declared a variant of "IsIn" for each "LongInt" and "String". So for each >>> "IsIn" specialization with different types new code is

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Dennis Poon
What about code size? The code size for one unit is the same as if you had (in that example) declared a variant of "IsIn" for each "LongInt" and "String". So for each "IsIn" specialization with different types new code is generated if it does not yet exist in that unit. This means that

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Florian Klämpfl
Am 02.08.2013 17:46, schrieb Sven Barth: > - using an array declared as a ranged array (array[0..2] of LongInt) the > for-loop is inlined and optimized a bit (especially depending on the > optimization settings), but the compiler does not yet fold the loop... > At least I fixed loop unrolling for

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Flávio Etrusco
On Fri, Aug 2, 2013 at 1:07 PM, Sven Barth wrote: > On 02.08.2013 17:50, Flávio Etrusco wrote: >> >> On Fri, Aug 2, 2013 at 12:34 PM, Sven Barth >> wrote: >>> >>> On 02.08.2013 17:01, Mattias Gaertner wrote: On Fri, 02 Aug 2013 13:18:53 +0200 Sven Barth wrote: >> >> >> (...)

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
On 02.08.2013 17:50, Flávio Etrusco wrote: On Fri, Aug 2, 2013 at 12:34 PM, Sven Barth wrote: On 02.08.2013 17:01, Mattias Gaertner wrote: On Fri, 02 Aug 2013 13:18:53 +0200 Sven Barth wrote: (...) What about code size? The code size for one unit is the same as if you had (in that exa

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
On 02.08.2013 17:46, Sven Barth wrote: On 02.08.2013 17:34, Sven Barth wrote: If you'd declare the "IsIn" function as "inline" and the compiler would correctly handle this(*1) the compiler could in theory be able to fold the complete for-loop together in the example I gave (because only constant

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Flávio Etrusco
On Fri, Aug 2, 2013 at 12:34 PM, Sven Barth wrote: > On 02.08.2013 17:01, Mattias Gaertner wrote: >> >> On Fri, 02 Aug 2013 13:18:53 +0200 >> Sven Barth wrote: (...) >> What about code size? > > > The code size for one unit is the same as if you had (in that example) > declared a variant of "Is

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
On 02.08.2013 17:34, Sven Barth wrote: If you'd declare the "IsIn" function as "inline" and the compiler would correctly handle this(*1) the compiler could in theory be able to fold the complete for-loop together in the example I gave (because only constants are used there). I don't know though w

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
On 02.08.2013 17:01, Mattias Gaertner wrote: On Fri, 02 Aug 2013 13:18:53 +0200 Sven Barth wrote: [...] === source begin === program tgenfuncs; {$modeswitch result} generic function IsIn(aElement: T; const aArray: array of T): Boolean; var elem: T; begin for elem in aArray do

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
On 02.08.2013 15:00, Anthony Walter wrote: Wow, that looks great Sven. I've been wanting generic functions for a long time. Would it be possible to add constraints like must override operators =, <, or > ... and possibly +, -, /, *, and, or, shl, shr, div, mod? I had the idea already myself to

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Mattias Gaertner
On Fri, 02 Aug 2013 13:18:53 +0200 Sven Barth wrote: >[...] > === source begin === > > program tgenfuncs; > > {$modeswitch result} > > generic function IsIn(aElement: T; const aArray: array of T): Boolean; > var >elem: T; > begin >for elem in aArray do > if elem = aElement then >

Re: [fpc-devel] Little feature teaser

2013-08-02 Thread Anthony Walter
Wow, that looks great Sven. I've been wanting generic functions for a long time. Would it be possible to add constraints like must override operators =, <, or > ... and possibly +, -, /, *, and, or, shl, shr, div, mod? In this way you could write: function Sum(const Items: TArray): T; var I: T;

[fpc-devel] Little feature teaser

2013-08-02 Thread Sven Barth
Hello together! Just a little feature teaser what I'm currently working on when I find the time. :) === source begin === program tgenfuncs; {$modeswitch result} generic function IsIn(aElement: T; const aArray: array of T): Boolean; var elem: T; begin for elem in aArray do if elem =