Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Andrew Pennebaker
Something's wrong with the makefiles. I checked out the Subversion trunkhttp://svn.freepascal.org/svn/fpc/trunk/and ran sudo make install. Partway through the process, when I run fpc in a new terminal, I get: $ fpc Free Pascal Compiler version 2.7.1 But when make finishes installing, I run fpc

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Andrew Pennebaker
I forcibly sudo cp ppc386 /usr/local/bin/fpc, mitigating the issue. Yeah, something in the makefile installation process is definitely moving over an older version. (I deleted the whole directory for the v2.4.4 subversion, so that's not the problem.) Cheers, Andrew Pennebaker www.yellosoft.us

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Andrew Pennebaker
Sven, recap: I want to make a GenArray function that returns an array populated by a generator anonymous function. For example, GenString would generate a random string by doing GenArray(GenChar). Users could create their own generators, e.g. GenTree wrapping around GenArray(GenLeaf), GenGraph

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Sven Barth
Am 31.10.2011 08:52, schrieb Andrew Pennebaker: paycheck.pas: unit Paycheck; interface type generic TArrayT = array of T; generic TFnT = function() : T; function GenInt () : TFninteger; function GenBool() : TFnboolean; function GenChar() : TFnchar; function GenArray(gen : TFnT) :

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Jonas Maebe
On 31 Oct 2011, at 08:36, Andrew Pennebaker wrote: I forcibly sudo cp ppc386 /usr/local/bin/fpc, mitigating the issue. Yeah, something in the makefile installation process is definitely moving over an older version. Create a symlink from /usr/local/bin/ppc386 to

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Andrew Pennebaker
Sven, awesome! Looks like FPC will be getting some exciting features in the near future. Jonas, make install does, however, overwrite /usr/local/bin/fpc, which is not a symlink, with an old version during install. Try running fpc -version halfway and after make install. Cheers, Andrew

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Jonas Maebe
On 31 Oct 2011, at 18:29, Andrew Pennebaker wrote: Jonas, make install does, however, overwrite /usr/local/bin/fpc, which is not a symlink, with an old version during install. Try running fpc -version halfway and after make install. The fpc binary does not have a version number. It reports

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Sven Barth
On 31.10.2011 18:29, Andrew Pennebaker wrote: Sven, awesome! Looks like FPC will be getting some exciting features in the near future. Only time will tell whether it's the near future. Also these features are meant to be Delphi compatible (except the point that FPC will support global

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-31 Thread Andrew Pennebaker
Jonas: Thanks, I'll use fpc -iV from now on. But make install still puts an fpc binary in /usr/local/bin that reports 2.7.1 and then overwrites *something* so that a second fpc call reports 2.4.4. Cheers, Andrew Pennebaker www.yellosoft.us On Mon, Oct 31, 2011 at 1:36 PM, Jonas Maebe

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-21 Thread Graeme Geldenhuys
On 2011-10-20 17:08, Andrew Pennebaker wrote: I'll just wait for v2.6 then. No need to wait, checkout the fixes_2_6 branch, which is currently at version 2.5.1, but will become the v2.6.0 release. This also means you will help test the future 2.6.0 release and catch any possible bugs _before_

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-21 Thread Sven Barth
Am 20.10.2011 17:08, schrieb Andrew Pennebaker: 2.6, eh? Awesome. I'm using the SVN trunk, but it's not working for me for some reason. I'll just wait for v2.6 then. Didn't you just say that you're using 2.4.4? Trunk is currently 2.7.1. Regards, Sven

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-20 Thread Sven Barth
Am 19.10.2011 20:08, schrieb Andrew Pennebaker: Right, I tried just {$mode delphi} and just generic, and when both failed I tried them at the same time. Maybe I'm not using a recent enough version? Free Pascal Compiler version 2.4.4 [2011/05/01] for i386 That's why I said trunk. Trunk is the

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-20 Thread Andrew Pennebaker
2.6, eh? Awesome. I'm using the SVN trunk, but it's not working for me for some reason. I'll just wait for v2.6 then. Cheers, Andrew Pennebaker www.yellosoft.us On Thu, Oct 20, 2011 at 2:19 AM, Sven Barth pascaldra...@googlemail.comwrote: Am 19.10.2011 20:08, schrieb Andrew Pennebaker:

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-20 Thread waldo kitty
On 10/20/2011 11:08, Andrew Pennebaker wrote: 2.6, eh? Awesome. I'm using the SVN trunk, but it's not working for me for some reason. this is why the latest version of the compiler, 2.4.4 is the one supported ;) I'll just wait for v2.6 then. always another possibility... depending on the

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 18.10.2011 21:59, schrieb Jonas Maebe: On 18 Oct 2011, at 21:55, Sven Barth wrote: type TGenArrayT = array of T; // this should work in trunk already function ConcatT(Arr1, Arr2: TGenArrayT): TGenArrayT; begin SetLength(Result, Length(aArray1) + Length(aArray2)); if

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 18.10.2011 23:08, schrieb Andrew Pennebaker: Barth, something's not quite right. I've compiled and installed the trunk version of fpc, but it won't recognize this syntax. paycheck.pas: unit Paycheck; interface type TArrayT = array of T; ... Trace: fpc example.pas Compiling example.pas

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? copy () ? :-)

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Andrew Pennebaker
Sven, I added the {$mode delphi} macro and prefaced each type with the generic specification. I'm still getting errors. paycheck.pas: unit Paycheck; {$mode delphi} interface type generic TArrayT = array of T; generic TFnT = function() : T; ... Trace: fpc example.pas Compiling

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Jonas Maebe
On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference- counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 09:59, schrieb Marco van de Voort: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 10:01, schrieb Andrew Pennebaker: Sven, I added the {$mode delphi} macro and prefaced each type with the generic specification. I'm still getting errors. Either add {$mode delphi} XOR generic E.g. Solution 1: unit Foo; interface type generic TGenArrayT = array of T; ...

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? For-loops. copy () ? :-) copy() cannot be used to concatenate two arrays, because it is a function

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Sven Barth
Am 19.10.2011 10:27, schrieb Jonas Maebe: On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about these... what would the correct way to copy

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Marco van de Voort
In our previous episode, Sven Barth said: Right... I tend to forget about these... what would the correct way to copy an array of ref counted types? E.g. an array of string? copy () ? :-) I thought about copy, too, but how would you implement a generic concat using copy (or even

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Andrew Pennebaker
Right, I tried just {$mode delphi} and just generic, and when both failed I tried them at the same time. Maybe I'm not using a recent enough version? Free Pascal Compiler version 2.4.4 [2011/05/01] for i386 Cheers, Andrew Pennebaker www.yellosoft.us On Wed, Oct 19, 2011 at 4:34 AM, Sven Barth

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-19 Thread Florian Klämpfl
Am 19.10.2011 10:49, schrieb Sven Barth: Am 19.10.2011 10:27, schrieb Jonas Maebe: On 19 Oct 2011, at 09:59, Marco van de Voort wrote: In our previous episode, Sven Barth said: This implementation will result in crashes if T is a reference-counted type. Right... I tend to forget about

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Vladimir Zhirov
Andrew Pennebaker wrote: thrice :: a - [a] thrice x = [x, x, x] I know the answer involves generics, but the docs don't offer examples using Free Pascal's built-in generic types. The solution would require generic functions, these are implemented in FPC trunk only. In the latest release

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Sven Barth
Am 18.10.2011 10:52, schrieb Vladimir Zhirov: The solution would require generic functions, these are implemented in FPC trunk only. Generic functions are NOT implemented in trunk (at least as far as I know...). Regards, Sven ___ fpc-pascal

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Vladimir Zhirov
Sven Barth wrote: Generic functions are NOT implemented in trunk (at least as far as I know...). Ouch, sorry. I read about generic procedural types at New features trunk wiki page and thought it was what OP need. Andrew, I apologize for misinformation and thanks Sven for correcting me.

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Andrew Pennebaker
Thrice is designed to work for *any* array type, e.g. arrays of arrays of arrays of bytes. Even if I hardcoded several thousand possible types, Thrice wouldn't work for custom user types. If you do find a way to make this work, please let me know. Cheers, Andrew Pennebaker www.yellosoft.us On

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Andrew Pennebaker
In particular, if anyone knows a way to implement a general concatenation function Concat(Arr1, Arr2), let me know. Cheers, Andrew Pennebaker www.yellosoft.us On Tue, Oct 18, 2011 at 1:59 PM, Andrew Pennebaker andrew.penneba...@gmail.com wrote: Thrice is designed to work for *any* array

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Jonas Maebe
On 18 Oct 2011, at 20:03, Andrew Pennebaker wrote: In particular, if anyone knows a way to implement a general concatenation function Concat(Arr1, Arr2), let me know. I'm under the impression that you are trying to program in a statically typed language the same way as you'd use a

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Sven Barth
On 18.10.2011 21:30, Jonas Maebe wrote: On 18 Oct 2011, at 20:03, Andrew Pennebaker wrote: In particular, if anyone knows a way to implement a general concatenation function Concat(Arr1, Arr2), let me know. I'm under the impression that you are trying to program in a statically typed

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-18 Thread Andrew Pennebaker
Barth, something's not quite right. I've compiled and installed the trunk version of fpc, but it won't recognize this syntax. paycheck.pas: unit Paycheck; interface type TArrayT = array of T; ... Trace: fpc example.pas Compiling example.pas Compiling paycheck.pas paycheck.pas(4,8) Fatal:

[fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-17 Thread Andrew Pennebaker
Haskell lets you define functions like thrice, which accepts an element of type a and returns a list of the element repeated three times, for any data type a. thrice :: a - [a] thrice x = [x, x, x] I know the answer involves generics, but the docs don't offer examples using Free Pascal's

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-17 Thread Marco van de Voort
In our previous episode, Andrew Pennebaker said: thrice :: a - [a] thrice x = [x, x, x] I know the answer involves generics, but the docs don't offer examples using Free Pascal's built-in generic types. There is no built in list type, generic or not, and no way to define new operators. All

Re: [fpc-pascal] How can I implement thrice in Free Pascal?

2011-10-17 Thread Andrew Pennebaker
Can this be done with arrays? I didn't mean to be too specific; I'd be happy with any generic collection that could do this. Cheers, Andrew Pennebaker www.yellosoft.us On Mon, Oct 17, 2011 at 6:08 PM, Marco van de Voort mar...@stack.nl wrote: In our previous episode, Andrew Pennebaker said: