Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 Length(aArray1) 0 then Move(aArray1[0], Result[0], Length(aArray1) * SizeOf(T)); if Length(aArray2) 0 then Move(aArray2[0], Result[Length(aArray1)], Length(aArray2) * SizeOf(T)); end; 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? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 Compiling paycheck.pas paycheck.pas(4,8) Fatal: Syntax error, = expected but found Fatal: Compilation aborted Either my syntax is wrong, or trunk doesn't have the syntax, or I'm having trouble getting the trunk version. You either need to add {$mode delphi} between unit Paycheck; and interface or you need to write it like this (though I haven't tested it): type generic TArrayT = array of T; Regards, Sven PS: It's more polite to use the first name when addressing persons in a mailing list. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] CGI under Freepascal
On 18/10/2011 16:51, Michael Van Canneyt wrote: You can always search for powtils, but as far as I know it is unmaintained. I use powtils (aka pwu), and it works very well. We have 3 CGI apps developed with powtils, connecting to a database backend etc. It is easy to use and relatively easy to deploy your CGI apps. Here is the last stable version I found - and the one we use. The latest code from the powtils repository simply did not compile for me. http://opensoft.homeip.net:8080/~graemeg/pwu-1.6.0.2.tar.gz Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting Hardware information in Linux
On 18/10/2011 21:44, Michael Van Canneyt wrote: use DBUS to query HAL. Normally you should get most of the info. I wrote an article on how to do this in FPC. if you want, I can send it to you. Would you mind sending me that article too, please. I'm using Turbo Power's OnGuard in our products, and improved the hardware detection code under Linux (CPU, network card, OS, user, HDD etc), but I did not use DBUS at all, I simply parsed the data in /proc/* and /dev/disk/* The hard drive make and serial number was a tough one, especially without forcing root access, but I did manage. I also asked in the mailing list about other distros and if they have the same /dev/disk/* information, and most modern Linux distros did. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Stack corruption setting UnicodeString Char
Hello, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1); System.Move(source^, ansistr[1], len); ansistr[len+1] := #0; SetLength(ansistr, len); And it works fine. You get a string with correct length and a final #0 terminator. Now, I simply tryed the same code for a unicodestring, and it corrupts my stack: procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt); var widestr: unicodestring; begin {$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif} // Copy the originating string taking into account the specified length SetLength(widestr, len+1); System.Move(source^, widestr[1], len*2); PWideChar(@widestr)[len] := #0; // --- This corrupts the stack SetLength(widestr, len); I already fixed the problem by simply not setting this last widechar to #0, but now I got puzzled: Any ideas why this doesn't work? It crashes only a bit after this procedure, but I found that this was the statement which caused the problem. -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 18.10.2011 21:42, schrieb Sven Barth: For anonymous functions you can take a look at Embarcadero's Delphi help here: http://docwiki.embarcadero.com/RADStudio/en/Anonymous_Methods_in_Delphi The Embarcadero style of anonymous functions does not satify me. myFunc := function(x, y: Integer): Integer begin Result := x + y; end; This is not easier than writing: function Bla(x, y: Integer): Integer begin Result := x + y; end; myfunc := @Bla; I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; But this makes it hard to read. Of course it would be nice to have anonymous functions or even lambdas (think about integrated languages like LinQ). But maybe Pascals strength of easy readable code gets lost. Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting Hardware information in Linux
On 19/10/2011 00:31, Den Jean wrote: read the output of lshw or read its source on how to do it yourself. problems with that is that to get most of the information you must run lshw as super-user (root). eg: Serial numbers, product codes, vendor names etc are all missing from the output if you don't run it as root. :-( I guess Linux takes security really serious when it comes to hardware information. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Stack corruption setting UnicodeString Char
Am 19.10.2011 09:13, schrieb Felipe Monteiro de Carvalho: Hello, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1); System.Move(source^, ansistr[1], len); ansistr[len+1] := #0; SetLength(ansistr, len); And it works fine. You get a string with correct length and a final #0 terminator. Now, I simply tryed the same code for a unicodestring, and it corrupts my stack: procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt); var widestr: unicodestring; begin {$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif} // Copy the originating string taking into account the specified length SetLength(widestr, len+1); System.Move(source^, widestr[1], len*2); PWideChar(@widestr)[len] := #0; //--- This corrupts the stack SetLength(widestr, len); Why don't you use the same statement as for the AnsiString version? E.g. widestr[len+1] := #0; Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Stack corruption setting UnicodeString Char
On Wed, October 19, 2011 09:13, Felipe Monteiro de Carvalho wrote: Hi, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1); System.Move(source^, ansistr[1], len); ansistr[len+1] := #0; SetLength(ansistr, len); And it works fine. You get a string with correct length and a final #0 terminator. Now, I simply tryed the same code for a unicodestring, and it corrupts my stack: procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt); var widestr: unicodestring; begin {$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif} // Copy the originating string taking into account the specified length SetLength(widestr, len+1); System.Move(source^, widestr[1], len*2); PWideChar(@widestr)[len] := #0; // --- This corrupts the stack SetLength(widestr, len); I already fixed the problem by simply not setting this last widechar to #0, but now I got puzzled: Any ideas why this doesn't work? It crashes only a bit after this procedure, but I found that this was the statement which caused the problem. Sorry for a silly question, but why the difference between the two implementations (i.e. why not addressing the WideStr element directly without the typecast)? Moreover, even if using the PWideChar, I believe that the correct version would be without the '@' (i.e.: PWideChar(widestr)[len] := #0), wouldn't it? Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 () ? :-) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 example.pas Compiling paycheck.pas paycheck.pas(5,32) Error: Identifier not found T paycheck.pas(5,32) Error: Error in type definition paycheck.pas(6,2) Error: This type can't be a generic paycheck.pas(6,33) Error: Identifier not found T paycheck.pas(7,1) Error: This type can't be a generic paycheck.pas(7,25) Fatal: Syntax error, ; expected but found Fatal: Compilation aborted Cheers, Andrew Pennebaker www.yellosoft.us On Wed, Oct 19, 2011 at 2:28 AM, Sven Barth pascaldra...@googlemail.comwrote: 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 Compiling paycheck.pas paycheck.pas(4,8) Fatal: Syntax error, = expected but found Fatal: Compilation aborted Either my syntax is wrong, or trunk doesn't have the syntax, or I'm having trouble getting the trunk version. You either need to add {$mode delphi} between unit Paycheck; and interface or you need to write it like this (though I haven't tested it): type generic TArrayT = array of T; Regards, Sven PS: It's more polite to use the first name when addressing persons in a mailing list. __**_ fpc-pascal maillist - fpc-pascal@lists.freepascal.**orgfpc-pascal@lists.freepascal.org http://lists.freepascal.org/**mailman/listinfo/fpc-pascalhttp://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Stack corruption setting UnicodeString Char
2011/10/19 Tomas Hajny xhaj...@hajny.biz: Sorry for a silly question, but why the difference between the two implementations (i.e. why not addressing the WideStr element directly without the typecast)? Actually it should be a pointer operation in the ansistring version too, because setting chars in a string calls UniqueString, which is undesirable and inneficient. Moreover, even if using the PWideChar, I believe that the correct version would be without the '@' (i.e.: PWideChar(widestr)[len] := #0), wouldn't it? Good idea! I think you found the problem. -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 19.10.2011 09:31, schrieb Michael Fuchs: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods should differ here. Also the example given by Embarcadero is a bit boring. The interesting thing about anonymous methods (and nested functions types in FPC) is that they can access variables of the surrounding function (at least I hope that I've understand it correctly that nested function types can do that). E.g. TIntegerFunc = reference to function: Integer; procedure SomeOtherProc(aFunc: TIntegerFunc); ... procedure Foo; var x: Integer; begin x := 42; SomeOtherProc(function: Integer; begin Result := x; end;); end; I haven't tested that, but from the description that should work. The FPC equivalent should be (not tested as well): type TIntegerFunc = function: Integer is nested; procedure SomeOtherProc(aFunc: TIntegerFunc); ... procedure Foo; var x: Integer; function ReturnX: Integer; begin Result := x; end; begin x := 42; SomeOtherProc(@ReturnX); end; Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Stack corruption setting UnicodeString Char
Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com hat am 19. Oktober 2011 um 09:13 geschrieben: Hello, Usually when we work with PChars we do things like this to set the final terminator: var ansistr: ansistring; begin // Copy the originating string taking into account the specified length SetLength(ansistr, len+1); System.Move(source^, ansistr[1], len); ansistr[len+1] := #0; SetLength(ansistr, len); And it works fine. You get a string with correct length and a final #0 terminator. I never saw such code for ansistring. Only for shortstring. SetLength(ansistring) already allocates memory for the header+len+1, creates the header and sets the len+1 character to #0. Simply do: SetLength(ansistr, len); if len1 then System.Move(source^, ansistr[1], len); Now, I simply tryed the same code for a unicodestring, and it corrupts my stack: procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt); var widestr: unicodestring; begin {$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif} // Copy the originating string taking into account the specified length SetLength(widestr, len+1); System.Move(source^, widestr[1], len*2); PWideChar(@widestr)[len] := #0; // --- This corrupts the stack This would corrupt the stack for ansistring too. This would only work for shortstring. widestr is a unicodestring is a pointer to widechar. PWideChar(widestr)[len] := #0; SetLength(widestr, len); I already fixed the problem by simply not setting this last widechar to #0, but now I got puzzled: Any ideas why this doesn't work? It crashes only a bit after this procedure, but I found that this was the statement which caused the problem. Mattias___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting Hardware information in Linux
Hello, On 2011-10-18 22:44, Michael Van Canneyt wrote: use DBUS to query HAL. Normally you should get most of the info. I wrote an article on how to do this in FPC. if you want, I can send it to you. Could you send it to me as well? Regards, Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Stack corruption setting UnicodeString Char
On Wed, Oct 19, 2011 at 10:11 AM, Mattias Gaertner nc-gaert...@netcologne.de wrote: I never saw such code for ansistring. Only for shortstring. Indeed, I copied some code from the RTL and it seams that I inadvertedly copied code for shortstring instead of ansistring =o I fixed this in rev 32977 in the Pascal Widestring Manager -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Hi Andrew, first of all my /first/ name is Lukasz. Would you /like/ me to use your surname to refer to yourself ? Second you seem to be sending the same message twice in one post (once as plain text the other as HTML) and quoted/printable encoding to make matters even worse. Please teach your (gmail ?) to behave. Third you're top-posting and this is is a no-no to many; We're not your corporate friends who are on top of things by definition, we have our lives and we read from the beginning to refresh on the matter. Fourth, you're leaving too much of the quote below your answer, for what exactly? Save electrons, they are becoming scarce. Fourth and I won't go into technicalities here but what is it exactly you want to achieve by trying to make FPC bend over backwards ? L. On 18/10/2011 19:10, Andrew Pennebaker wrote: [...cut quote...] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 array of string? For-loops. copy () ? :-) copy() cannot be used to concatenate two arrays, because it is a function that returns a new array with contantes of (a potentially sub- array of) the original array. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 string? copy () ? :-) I thought about copy, too, but how would you implement a generic concat using copy (or even just an array of String one)? Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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; ... Solution 2: unit Foo; {$mode delphi} interface type TGenArrayT = array of T; I just tested. Both work. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 19.10.2011 10:16, schrieb Sven Barth: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods should differ here. Allow both, like it is already allowed in Pascal: if True then DoSomething; if True then begin DoSomething; DoSomethingMore; Etc; end; If a function only contains one statement it is not a codeblock. Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 that returns a new array with contantes of (a potentially sub- array of) the original array. True. I only reacted on the last bit though. Create a deep copy. Not the application which copies to a certain element number. There is no procedure for that. There is a procedure to do it the other way around though (get sub array from array) called slice. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiling sources obtained via SVN
Am 18.10.2011 12:06, schrieb brian: The first problem I see is that there are actually two makefiles in the fpc directory, Makefile dated 31st Aug 2011 and Makefile.fpc dated 13th Aug 2011. This is normal. The Makefile.fpc basically contain the important parts of the makefile (which units are used on which system etc.) and are used to generate the Makefile using the utility fpcmake which is found in utils/fpcm. make -f Makefile build No need to use -f. make defaults to Makefile, makefile and some others. [snip] /usr/lib64/libgdb.a(dwarf2read.o): In function `dwarf2_read_section': (.text+0x224e): undefined reference to `inflate' /usr/lib64/libgdb.a(dwarf2read.o): In function `dwarf2_read_section': (.text+0x2262): undefined reference to `inflateReset' /usr/lib64/libgdb.a(dwarf2read.o): In function `dwarf2_read_section': (.text+0x2275): undefined reference to `inflateEnd' /usr/lib64/libbfd.a(compress.o): In function `bfd_uncompress_section_contents': /build/buildd/binutils-2.20.1/builddir-single/bfd/../../bfd/compress.c:96: undefined reference to `inflateInit_' /build/buildd/binutils-2.20.1/builddir-single/bfd/../../bfd/compress.c:103: undefined reference to `inflate' /build/buildd/binutils-2.20.1/builddir-single/bfd/../../bfd/compress.c:106: undefined reference to `inflateReset' /build/buildd/binutils-2.20.1/builddir-single/bfd/../../bfd/compress.c:108: undefined reference to `inflateEnd' fp.pas(552,1) Error: Error while linking fp.pas(552,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted make[4]: *** [fp] Error 1 make[4]: Leaving directory `/data2/sources/subversion/fpc/ide' make[3]: *** [buildfp] Error 2 make[3]: Leaving directory `/data2/sources/subversion/fpc/ide' make[2]: *** [gdb] Error 2 make[2]: Leaving directory `/data2/sources/subversion/fpc/ide' make[1]: *** [ide_all] Error 2 make[1]: Leaving directory `/data2/sources/subversion/fpc' make: *** [build-stamp.x86_64-linux] Error 2 This seems to be related to building the textmode IDE. If you don't need the textmode IDE you can try the following workaround: Open the Makefile in the base directory and search for IDE=1. Remove the 1 so that it reads IDE=. Save the file and try again. This should stop the building (and thus its linking) of the textmode IDE. Perhaps a NOIDE option should be added to the base makefile... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 an array of ref counted types? E.g. an array of string? For-loops. *sigh* For-loops it is then... copy () ? :-) copy() cannot be used to concatenate two arrays, because it is a function that returns a new array with contantes of (a potentially sub-array of) the original array. That's what I remembered about copy as well. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 just an array of String one)? (as said I only reacted on the other bit). Not without creating a compiler magic function that does it for a refcounted types as opposite to slice(). But then you start down a slippery slope trying to create a list based language, and LISP already has been invented :-) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiling sources obtained via SVN
brian wrote: I assume there's an expectation that the sources downloaded from trunk should compile on all platforms? I've just updated to 19505, and attempting to build on Linux Mint 9 64-bit causes a few problems. The first problem I see is that there are actually two makefiles in the fpc directory, Makefile dated 31st Aug 2011 and Makefile.fpc dated 13th Aug 2011. However, unless I'm missing some switch or other, doing a make distclean followed by make -f Makefile build generates a LARGE number of unresolved references. With apologies to anyone still on dial-up, the error messages are posted below. I do have v2.4.2-0 installed on my machine, this was from installing the combined FPC and Lazarus .DEBs from sourceforge, but presumably the make should be working with the files in the subversion tree? Brian. ... /data2/sources/subversion/fpc/packages/gdbint/units/x86_64-linux/gdbint.o: In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB__INIT': gdbint.pp:(.text+0xfde): undefined reference to `deprecated_create_breakpoint_hook' /data2/sources/subversion/fpc/packages/gdbint/units/x86_64-linux/gdbint.o: In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB_DONE': gdbint.pp:(.text+0x103f): undefined reference to `deprecated_create_breakpoint_hook' /usr/lib64/libgdb.a(varobj.o): In function `construct_visualizer': (.text+0x83d): undefined reference to `_Py_NoneStruct' So either sort out your libgdb, which is not part of FPC and needs to be copied into the build directory, or build with make distclean make NOGDB=1 all I think that NOGDB is right, but I'm working from memory here. In general I build without libgdb at any sign of problems since it's only used in the fp (text) IDE, however I've successfully built it on all platforms here except ARM (not tested on x64 since I don't have one). -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiling sources obtained via SVN
Sven Barth wrote: This seems to be related to building the textmode IDE. If you don't need the textmode IDE you can try the following workaround: Open the Makefile in the base directory and search for IDE=1. Remove the 1 so that it reads IDE=. Save the file and try again. This should stop the building (and thus its linking) of the textmode IDE. Perhaps a NOIDE option should be added to the base makefile... I'm fairly sure that somebody did something about this recently, after problems were reported building on some platforms. I don't know how many people rely on the IDE and in particular on the debugger, even I have taken to using Lazarus for this. I think possibly that the time has come that without an explicit option to include it the debugger (i.e. calls to libgdb) should be excluded by default. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] 3-tier database applications with FPC
Hi, Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). TClientDataset also missed some vital features, and the state of WebServices was also not complete. Here is the original message thread: http://www.mail-archive.com/lazarus@lazarus.freepascal.org/msg00861.html So after 3 year, what has changed? Is the missing parts already implement, and is a Midas / Datasnap style 3-tier application possible with FPC? I also believe Borland/CodeGear/Embarcadero released the Midas source code in post Delphi 7 versions. Anybody have success in compiling that code with FPC? Yes I know you can't release such code, and yes I know Datasnap will probably only work with Windows. But from my Kylix 3 manual it mentions TSoapConnection and WebServices for multi-tier development, so was wondering if FPC had no alternative, if I could possibly compile that Kylix 3 code using FPC - anybody tried this before? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Delphi's anonymous functions in Free Pascal
19.10.2011 12:16, Sven Barth пишет: E.g. TIntegerFunc = reference to function: Integer; procedure SomeOtherProc(aFunc: TIntegerFunc); ... procedure Foo; var x: Integer; begin x := 42; SomeOtherProc(function: Integer; begin Result := x; end;); end; I haven't tested that, but from the description that should work. The FPC equivalent should be (not tested as well): type TIntegerFunc = function: Integer is nested; procedure SomeOtherProc(aFunc: TIntegerFunc); ... procedure Foo; var x: Integer; function ReturnX: Integer; begin Result := x; end; begin x := 42; SomeOtherProc(@ReturnX); end; Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal But _real_ functional equivalent of Delphi's function reference if COM-interface based functor. F.e. TMyFuction = reference to function: Integer; and IMyFunction = interface function Invoke:Integer; end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
In our previous episode, Graeme Geldenhuys said: Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Afaik sb was also working on porting midware (www.overbyte.be), but while I haven't look at it for years I assume that is very windows centric. TClientDataset also missed some vital features, and the state of WebServices was also not complete. Here is the original message thread: http://www.mail-archive.com/lazarus@lazarus.freepascal.org/msg00861.html So after 3 year, what has changed? Is the missing parts already implement, and is a Midas / Datasnap style 3-tier application possible with FPC? I take 3-tier above as a general framework for 3-tier, not necessarily a Datasnap compatible layer. I also believe Borland/CodeGear/Embarcadero released the Midas source code in post Delphi 7 versions. No, starting only with D2010 afaik, and only enterprise and higher SKUs Anybody have success in compiling that code with FPC? That would be very hard since it is C++. Yes I know you can't release such code, and yes I know Datasnap will probably only work with Windows. But from my Kylix 3 manual it mentions TSoapConnection and WebServices for multi-tier development, so was wondering if FPC had no alternative, if I could possibly compile that Kylix 3 code using FPC - anybody tried this before? Since Delphi XE2 last December you can make datasnap apps for OS X and very experimental for iOS. Linux is said to follow in the next release. However that is based on Firemonkey's ownerdrawn framework, and thus needs a separate codebase for the GUI. Firemonkey IS available for windows too though. Note that stuff like datasource remains the same, but how non visual db aware components are databound to FM visual components differs totally. There is no grid, but the stringgrid like has some databinding properties. To be honest, it looked a bit convoluted to me during the demo, but that might just be the inexperience. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal] Compiling sources obtained via SVN
In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB__INIT': gdbint.pp:(.text+0xfde): undefined reference to `deprecated_create_breakpoint_hook' /data2/sources/subversion/fpc/packages/gdbint/units/x86_64-linux/gdbint.o: In function `GDBINT$_$TGDBINTERFACE_$__$$_GDB_DONE': gdbint.pp:(.text+0x103f): undefined reference to `deprecated_create_breakpoint_hook' /usr/lib64/libgdb.a(varobj.o): In function `construct_visualizer': The problem is that you are using a system install GDb library /usr/lib64/libgdb.a This will most probably fail, as packages/gdbint will probably not find out the correct option that were used to generate this library. The absence of this particular symbol `deprecated_create_breakpoint_hook' probably means that your libgdb is older and still has `create_breakpoint_hook' symbol instead. But there are other problems that might appear as the library can be generated with different configure options that need different libraries (like using --with-python option ) The best way to generate a Free Pascal IDE is to rebuild gdb from source (best would be to use the latest port to your system or GDB 7.3 official GNU sources). Then use packages/gbint/gen-gdblib-inc.sh by copying that script to build/gdb directory and executing it from there. This generates copy-libs.sh script that can be used to copied the needed (at least the ones the script finds) library to a destination directory that is the required argument to that script. ./copy-libs.sh /path-to-trunk-svn/libgdb/OS_TARGET/CPU_TARGET/ where you would replace OS_TARGET by linux CPU_TARGET by x86_64 and /path-to-trunk by the real directory of the svn fpc trunk checkout (would be fpcsrc sub-directory if you checked out fpcbuild). It is probably an error in the Makefile to search for libgdb.a also in system directories as it leads to more troubles than anything else... Pierre Muller ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: Hi, Just over 3 years ago I asked about FPC support for creating 3-tier database applications. The answer was basically: it's not possible (unless you roll your own Midas / Datasnap code). TClientDataset also missed some vital features, and the state of WebServices was also not complete. Here is the original message thread: http://www.mail-archive.com/lazarus@lazarus.freepascal.org/msg00861.html So after 3 year, what has changed? Is the missing parts already implement, and is a Midas / Datasnap style 3-tier application possible with FPC? Out of the box: no. I also believe Borland/CodeGear/Embarcadero released the Midas source code in post Delphi 7 versions. Anybody have success in compiling that code with FPC? Yes I know you can't release such code, and yes I know Datasnap will probably only work with Windows. But from my Kylix 3 manual it mentions TSoapConnection and WebServices for multi-tier development, so was wondering if FPC had no alternative, if I could possibly compile that Kylix 3 code using FPC - anybody tried this before? Midas is written in C++, so that's not going to happen. I got sidetracked on web-development, so the 3-tier support per-se is missing. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. And it would only work with HTTP as the transport layer. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Reopen issue 20500: TSQLParser cant Parse Statements containing as
On 18-10-2011 7:13, Reinier Olislagers wrote: On 17-10-2011 20:57, Michael Van Canneyt wrote: Would it make sense to reopen this bug? ? Eh ? If indeed it is accepted, then yes please. Quite strange, because I implemented the SQL parser based on the official Firebird server docs. And it definitely was not allowed. But I'll test on 2.5, and if it indeed works, I'll of course implement it. Michael. Had a look through the Interbase 6 docs. The description on SELECT indeed mentions column aliases with AS but table aliases without them. Then the Firebird 2.5 Language Reference Update (8 October 2011, version 1.1, covers Firebird 2.5 and 2.5.1) http://www.firebirdsql.org/en/news/firebird-2-5-language-reference-update-12296/ doesn't explicitly say anything about table aliases with AS... I'll ask in the Firebird list, maybe the docs need updating. Confirmed: the IB 6 Langref needs updating ;) but that probably isn't going to happen. Firebird docs will be updated though. See http://tech.groups.yahoo.com/group/firebird-support/message/115445 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Thanks, I'll take a look. I take 3-tier above as a general framework for 3-tier, not necessarily a Datasnap compatible layer. Correct, it doesn't need to be compatible with Delphi. Any 3-tier support will do. I also believe Borland/CodeGear/Embarcadero released the Midas source code in post Delphi 7 versions. No, starting only with D2010 afaik, and only enterprise and higher SKUs Anybody have success in compiling that code with FPC? That would be very hard since it is C++. :-) Thanks for correctly me, I didn't know the details of each of those. However that is based on Firemonkey's ownerdrawn framework, and thus needs a separate codebase for the GUI. Firemonkey IS available for windows too though. FireMonkey seems to be missing many vital parts for a actual project development (lets ignore those silly 3D demos they love to show - which doesn't reflect real world applications). FireMonkey has no grids, no TAction, many missing events etc etc. It seems like a large rush job from Embarcadero. Also FireMonkey seems more geared towards mobile device applications (iPhone, iPad, Android), and not desktop business applications. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. I just finished watching a CodeRage 5 Datasnap demo. The guy said that XML packet transport is extremely slow (because XML is generally hard to parse). Simply changing to CSV packet format gave a 20x speed improvement, but obviously CSV is not self-describing. Is parsing JSON any faster than XML? Sorry if this is a stupid question, but I know near zero about JSON. OK, so it seems worth my while to port the tiOPF Remote Persistence Layer to FPC+Synapse (or maybe lNet) then. Based on an old message from Peter Hinrichsen, tiOPF can take care of everything for me, without 3rd party components or libraries, including some state information. He also mentioned that [at the time of his message] it was well unit tested and already used for 4 years in a production environment. The current tiOPF Remote Persistence Layer uses Indy's HTTP client server components and has two data packet formats it supports (one being more compressed). I'll dive into that code then and see what I can manage with FPC. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Strange, nowhere on the kbmMW website do I see any mention of Free Pascal Compiler or Lazarus IDE support. http://www.components4programmers.com/products/kbmmw/featurematrix/supporteddatabaseapi.htm http://www.components4programmers.com/products/kbmmw/featurematrix/supportedides.htm It mentions Kylix 3 support for under Linux, but not FPC. Maybe his website is just out of date? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. I just finished watching a CodeRage 5 Datasnap demo. The guy said that XML packet transport is extremely slow (because XML is generally hard to parse). Simply changing to CSV packet format gave a 20x speed improvement, but obviously CSV is not self-describing. It depends on a number of factors. I did extensive testing of the speed difference in XML and binary messaging. One of the conclusions was that you can gain an overall speed improvement of a factor 6 when switching from XML to binary messaging. Not using HTTP but a self-made TCP/IP protocol gets you another factor. SOAP over HTTP (the standard for webservices) has the incredible advantage that it is cross-platform, and meanwhile any language can handle it. The incredible downside is that it is slow and bulky. Our client/server apps used HTTP/SOAP it when we just started. It took us less than a week to realize this was a very bad idea, so we switched to TCP/IP and binary messages. Never looked back since. (and this was before I did the extensive testing) Is parsing JSON any faster than XML? Sorry if this is a stupid question, but I know near zero about JSON. Yes it is. It's much less verbose also, which means the transported packets are much smaller. OK, so it seems worth my while to port the tiOPF Remote Persistence Layer to FPC+Synapse (or maybe lNet) then. Based on an old message from Peter Hinrichsen, tiOPF can take care of everything for me, without 3rd party components or libraries, including some state information. He also mentioned that [at the time of his message] it was well unit tested and already used for 4 years in a production environment. The current tiOPF Remote Persistence Layer uses Indy's HTTP client server components and has two data packet formats it supports (one being more compressed). I'll dive into that code then and see what I can manage with FPC. If you do, then I'd be very interested in hearing about your progress. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On Wed, 19 Oct 2011, Graeme Geldenhuys wrote: On 2011-10-19 11:23, Marco van de Voort wrote: - kbmMW http://components4developers.com/ the author was on the Lazarus day in 2010. Strange, nowhere on the kbmMW website do I see any mention of Free Pascal Compiler or Lazarus IDE support. http://www.components4programmers.com/products/kbmmw/featurematrix/supporteddatabaseapi.htm http://www.components4programmers.com/products/kbmmw/featurematrix/supportedides.htm It mentions Kylix 3 support for under Linux, but not FPC. Maybe his website is just out of date? Yes. I know that the support is ready, but not widely advertized, because lazarus lacks binary package support. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On 2011-10-19 13:34, michael.vancann...@wisa.be wrote: factor 6 when switching from XML to binary messaging. Not using HTTP but a self-made TCP/IP protocol gets you another factor. Are both the binary message format and self-made TCP/IP protocol publicly available? Maybe that might be worth implementing in tiOPF too, as an optional setting to improve the remote persistence layer performance. Yes it is. It's much less verbose also, which means the transported packets are much smaller. Excellent, I'll try and add JSON support to tiOPF too. A quick look on the web at the JSON syntax, it does indeed looks much more human readable and simpler than XML. I'm not a big fan of XML at all. If you do, then I'd be very interested in hearing about your progress. I'll keep you informed. I'll probably start on this early next week. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
From: Graeme Geldenhuys graemeg.li...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, October 19, 2011 8:25 AM Subject: Re: [fpc-pascal] 3-tier database applications with FPC On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. I just finished watching a CodeRage 5 Datasnap demo. The guy said that XML packet transport is extremely slow (because XML is generally hard to parse). Simply changing to CSV packet format gave a 20x speed improvement, but obviously CSV is not self-describing. Is parsing JSON any faster than XML? Sorry if this is a stupid question, but I know near zero about JSON. I created a FastCGI based server that handles JSON requests from a Win32/Linux GUI app, that uses a custom made ORM similar to tiOPF and it works really fast, even on slow-long distance networks. I never had to do this, but as most modern http servers support gzip compression, one alternative to binary formats is to enable compression on server side, and decompress on client side. This approach has the advantage of JSON readability and the small size of binary format. Leonardo M. Ramé http://leonardorame.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On Wed, 19 Oct 2011, Leonardo M. Ramé wrote: From: Graeme Geldenhuys graemeg.li...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, October 19, 2011 8:25 AM Subject: Re: [fpc-pascal] 3-tier database applications with FPC On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. I just finished watching a CodeRage 5 Datasnap demo. The guy said that XML packet transport is extremely slow (because XML is generally hard to parse). Simply changing to CSV packet format gave a 20x speed improvement, but obviously CSV is not self-describing. Is parsing JSON any faster than XML? Sorry if this is a stupid question, but I know near zero about JSON. I created a FastCGI based server that handles JSON requests from a Win32/Linux GUI app, that uses a custom made ORM similar to tiOPF and it works really fast, even on slow-long distance networks. I never had to do this, but as most modern http servers support gzip compression, one alternative to binary formats is to enable compression on server side, and decompress on client side. This approach has the advantage of JSON readability and the small size of binary format. That's exactly what we do also. But in the case of large packages (we have datasets of 30.000 records), the JSON is really slow. The browser chokes already on a dataset of 3000 records, when using ExtJS =-) Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
- Original Message - From: michael.vancann...@wisa.be michael.vancann...@wisa.be To: Leonardo M. Ramé martinr...@yahoo.com; FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Cc: Sent: Wednesday, October 19, 2011 11:03 AM Subject: Re: [fpc-pascal] 3-tier database applications with FPC On Wed, 19 Oct 2011, Leonardo M. Ramé wrote: From: Graeme Geldenhuys graemeg.li...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Sent: Wednesday, October 19, 2011 8:25 AM Subject: Re: [fpc-pascal] 3-tier database applications with FPC On 2011-10-19 11:36, michael.vancann...@wisa.be wrote: Out of the box: no. OK, thanks. Do you know if TClientDataset has improved at all? Midas is written in C++, so that's not going to happen. I didn't know that. OTOH the web-development part has resulted in a ready-to-use packet transport layer. It's inefficient though, since it uses JSON or XML, but that can easily be adapted to support a 'binary' packet. I just finished watching a CodeRage 5 Datasnap demo. The guy said that XML packet transport is extremely slow (because XML is generally hard to parse). Simply changing to CSV packet format gave a 20x speed improvement, but obviously CSV is not self-describing. Is parsing JSON any faster than XML? Sorry if this is a stupid question, but I know near zero about JSON. I created a FastCGI based server that handles JSON requests from a Win32/Linux GUI app, that uses a custom made ORM similar to tiOPF and it works really fast, even on slow-long distance networks. I never had to do this, but as most modern http servers support gzip compression, one alternative to binary formats is to enable compression on server side, and decompress on client side. This approach has the advantage of JSON readability and the small size of binary format. That's exactly what we do also. But in the case of large packages (we have datasets of 30.000 records), the JSON is really slow. The browser chokes already on a dataset of 3000 records, when using ExtJS =-) Michael. In those cases, we use pagination. We allways ask for record 1-100, 101-200, and so on. Leonardo M. Ramé http://leonardorame.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] sqldb how to find a record fast with primary key
Hello, I am using sqldb to connect to a postgres database. Using wiki instructions, my final object is a TSQLQuery for each table. So, this basically is a TDataset and to read fields I know that I can use First(), Next(), EOF() and RecNo But these are rather slow. Many fields in the tables refer to the primary key in other tables, which does not match the RecNo. How can I jump fast a table to the record which has a particular PrimaryKey? thanks, -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] sqldb how to find a record fast with primary key
On Wednesday 19 October 2011 16.53:00 Felipe Monteiro de Carvalho wrote: Hello, I am using sqldb to connect to a postgres database. Using wiki instructions, my final object is a TSQLQuery for each table. So, this basically is a TDataset and to read fields I know that I can use First(), Next(), EOF() and RecNo But these are rather slow. Many fields in the tables refer to the primary key in other tables, which does not match the RecNo. How can I jump fast a table to the record which has a particular PrimaryKey? Use a local index and tlocalindex.find() (MSEgui). SQLdb has local index too AFAIK. MSEgui has additionally tlookupbuffer and fast lookup field linking by local index and direct data access without dataset scrolling. Martin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] 3-tier database applications with FPC
On 10/19/2011 07:05, Leonardo M. Ramé wrote: - Original Message - ...snip... I created a FastCGI based server that handles JSON requests from a Win32/Linux GUI app, that uses a custom made ORM similar to tiOPF and it works really fast, even on slow-long distance networks. I never had to do this, but as most modern http servers support gzip compression, one alternative to binary formats is to enable compression on server side, and decompress on client side. This approach has the advantage of JSON readability and the small size of binary format. That's exactly what we do also. But in the case of large packages (we have datasets of 30.000 records), the JSON is really slow. The browser chokes already on a dataset of 3000 records, when using ExtJS =-) Michael. In those cases, we use pagination. We allways ask for record 1-100, 101-200, and so on. Leonardo M. Ramé Exactly. Also, with ExtJS 4.0 they made a point of significantly speeding up most things. Usually, the problem with ExtJS 3.x is not with the slowness of JSON itself compared to binary communication, but with the thousands of DOM elements you need to create to display such a big set of data using javascript on client browser side. Of course, it is still a 4.0.x version at the moment, so I would wait until 4.1 at least before using it in a production environment. AB ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Hmm... I'm not really sure though, but I guess you could make use of array of const feature. See the documentation here: http://www.freepascal.org/docs-html/ref/refsu60.html -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Delphi-s-anonymous-functions-in-Free-Pascal-tp4911527p4918629.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 19.10.2011 10:16, schrieb Sven Barth: Am 19.10.2011 09:31, schrieb Michael Fuchs: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods should differ here. Also the example given by Embarcadero is a bit boring. The interesting thing about anonymous methods (and nested functions types in FPC) is that they can access variables of the surrounding function (at least I hope that I've understand it correctly that nested function types can do that). The main difference between anonymous methods and nested functions is that one can return a reference to an anonymous method from a function, the anonymous method can access local variables from that function and even after exiting the function, the variables are still valid. This means that local variables accessed in a anonymous method end up on the heap. However, I fail to see reasonable use cases for anonymous methods ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 pascaldra...@googlemail.comwrote: 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; ... Solution 2: unit Foo; {$mode delphi} interface type TGenArrayT = array of T; I just tested. Both work. Regards, Sven __**_ fpc-pascal maillist - fpc-pascal@lists.freepascal.**orgfpc-pascal@lists.freepascal.org http://lists.freepascal.org/**mailman/listinfo/fpc-pascalhttp://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How can I implement thrice in Free Pascal?
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 these... what would the correct way to copy an array of ref counted types? E.g. an array of string? For-loops. *sigh* For-loops it is then... Compared with the affort for ref. counting this is negliable imo. Modern processors don't perform that bad on a simple loop to copy memory. copy () ? :-) copy() cannot be used to concatenate two arrays, because it is a function that returns a new array with contantes of (a potentially sub-array of) the original array. That's what I remembered about copy as well. Copy does a one level deep copy. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Practical uses for referencable anonymous functions: (map f collection) This is the prototypical way to run a function over each element in a collection, returning the results. Example: (map (lambda (x) (+ x 1)) '(1 2 3)) - (2 3 4) (sort compare collection) When dealing with complex data types, the user may want to implement a custom compare function. (sort (lambda (x y) (- y:employee-id x:employeeid)) (list emp1 emp2 emp3)) - (emp3 emp1 emp2) (zip f collection1 collection2) Similar to map, zip runs a 2-input function over the elements of the collections, returning the results. (zip (lamba (x y) (+ x y)) '(1 2 3) '(4 5 6)) - (5 7 9) At first glance, each of these examples may seem pointless. Can't we implement the same behavior without referencing anonymous functions? Yes, we can, but only for a specific function. If you want your database library to allow users to customize sorting, you'll need referencable anonymous functions. If you've used a functional language, you know how powerful these little functions are, and you'll miss them and want to implement them in languages that don't have them. Cheers, Andrew Pennebaker www.yellosoft.us On Wed, Oct 19, 2011 at 2:04 PM, Florian Klämpfl flor...@freepascal.orgwrote: Am 19.10.2011 10:16, schrieb Sven Barth: Am 19.10.2011 09:31, schrieb Michael Fuchs: I would prefer a style like myfunc := @function(x, y: Integer): Integer Result := x + y; And how would you create more complex functions? In Pascal code blocks are started with begin and ended with end. I don't see a reason why anonymous methods should differ here. Also the example given by Embarcadero is a bit boring. The interesting thing about anonymous methods (and nested functions types in FPC) is that they can access variables of the surrounding function (at least I hope that I've understand it correctly that nested function types can do that). The main difference between anonymous methods and nested functions is that one can return a reference to an anonymous method from a function, the anonymous method can access local variables from that function and even after exiting the function, the variables are still valid. This means that local variables accessed in a anonymous method end up on the heap. However, I fail to see reasonable use cases for anonymous methods ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 19.10.2011 20:23, schrieb Andrew Pennebaker: Practical uses for referencable anonymous functions: For such applications one uses procedure variables in pascal. (map f collection) This is the prototypical way to run a function over each element in a collection, returning the results. Example: (map (lambda (x) (+ x 1)) '(1 2 3)) - (2 3 4) (sort compare collection) When dealing with complex data types, the user may want to implement a custom compare function. (sort (lambda (x y) (- y:employee-id x:employeeid)) (list emp1 emp2 emp3)) - (emp3 emp1 emp2) (zip f collection1 collection2) Similar to map, zip runs a 2-input function over the elements of the collections, returning the results. (zip (lamba (x y) (+ x y)) '(1 2 3) '(4 5 6)) - (5 7 9) At first glance, each of these examples may seem pointless. Can't we implement the same behavior without referencing anonymous functions? Yes, we can, but only for a specific function. If you want your database library to allow users to customize sorting, you'll need referencable anonymous functions. I still don't see why this cannot be done by procedure variables: one can easily pass a procedure reference to a compare function to any sort library call. The example is far from explaining why it is needed to be able to return a reference to an anonymous method to the outside of the enclosing function. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
Am 19.10.2011 20:30, schrieb Florian Klämpfl: I still don't see why this cannot be done by procedure variables: one can easily pass a procedure reference to a compare function to any sort library call. It is maybe easier to write a anonymous function inline than declaring a function and passing it with a reference to this function. Sometimes I miss them in FPC, but I am also not sure if this feature destroys the beauty of Pascal. Not easy. Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Delphi's anonymous functions in Free Pascal
From what I gather, procedure variables can indeed be referenced and passed around, etc. However, procedures do not return anything, so it's hard to chain them. In functional languages, it's handy to do several nested map(map(map f ... calls. Cheers, Andrew Pennebaker www.yellosoft.us On Wed, Oct 19, 2011 at 2:30 PM, Florian Klämpfl flor...@freepascal.orgwrote: Am 19.10.2011 20:23, schrieb Andrew Pennebaker: Practical uses for referencable anonymous functions: For such applications one uses procedure variables in pascal. (map f collection) This is the prototypical way to run a function over each element in a collection, returning the results. Example: (map (lambda (x) (+ x 1)) '(1 2 3)) - (2 3 4) (sort compare collection) When dealing with complex data types, the user may want to implement a custom compare function. (sort (lambda (x y) (- y:employee-id x:employeeid)) (list emp1 emp2 emp3)) - (emp3 emp1 emp2) (zip f collection1 collection2) Similar to map, zip runs a 2-input function over the elements of the collections, returning the results. (zip (lamba (x y) (+ x y)) '(1 2 3) '(4 5 6)) - (5 7 9) At first glance, each of these examples may seem pointless. Can't we implement the same behavior without referencing anonymous functions? Yes, we can, but only for a specific function. If you want your database library to allow users to customize sorting, you'll need referencable anonymous functions. I still don't see why this cannot be done by procedure variables: one can easily pass a procedure reference to a compare function to any sort library call. The example is far from explaining why it is needed to be able to return a reference to an anonymous method to the outside of the enclosing function. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal