[fpc-pascal] Community site

2014-02-09 Thread Florian Klämpfl
You might have noticed that the FPC community site is already down for some time. Since we are retiring the machine running the community site we decided not to migrate the community but add some new boards to the lazarus forum to reduce the need to maintain another bulletin board site. The lazarus

[fpc-pascal] List published properties of a class

2014-02-09 Thread Joao Morais
Hello list. I need to list all published properties declared in a class, iow, removing properties inherited from the parent. Up to now I am iterating typinfo.GetPropList, starting at: GetTypeData(PTypeInfo(TheClass.ClassParent.ClassInfo))^.PropCount; and it works (fpc 2.6.2). TheClass will n

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Fred van Stappen
> So: don't touch it! ;) > > Regards, > Sven Yep, many thanks for that clear answer. ;-) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Sven Barth
On 09.02.2014 19:10, patspiper wrote: On 09/02/14 18:47, Sven Barth wrote: On 09.02.2014 16:34, Flávio Etrusco wrote: In other words: dynamic arrays are like AnsiStrings without the copy-on-write semantics. I'd certainly wish Borland copied the COW semantics :-/ Dynamic arrays have full COW

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Florian Klämpfl
Am 09.02.2014 18:41, schrieb Jürgen Hestermann: > So it seems there is a copy-on-write *but* only when using SetLength. No. There is no COW, only ref. counting. SetLength just forces an unique instance of the array if needed. > What a very consistent design! There is a very good reason for this

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread patspiper
On 09/02/14 18:47, Sven Barth wrote: On 09.02.2014 16:34, Flávio Etrusco wrote: In other words: dynamic arrays are like AnsiStrings without the copy-on-write semantics. I'd certainly wish Borland copied the COW semantics :-/ Dynamic arrays have full COW semantics. It seems not: SetLength

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Jürgen Hestermann
Am 2014-02-09 17:47, schrieb Sven Barth: On 09.02.2014 16:34, Flávio Etrusco wrote: In other words: dynamic arrays are like AnsiStrings without the copy-on-write semantics. I'd certainly wish Borland copied the COW semantics :-/ Dynamic arrays have full COW semantics. Now I am fully confus

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Jürgen Hestermann
Am 2014-02-09 16:34, schrieb Flávio Etrusco: > In other words: dynamic arrays are like AnsiStrings without the > copy-on-write semantics. I'd certainly wish Borland copied the COW > semantics :-/ Yes. Therefore the issue that I described for dynamic arrays cannot occur for ansistrings. But COW c

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Sven Barth
On 09.02.2014 16:34, Flávio Etrusco wrote: In other words: dynamic arrays are like AnsiStrings without the copy-on-write semantics. I'd certainly wish Borland copied the COW semantics :-/ Dynamic arrays have full COW semantics. If Jürgen would have provided a full compilable example we could

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Sven Barth
On 09.02.2014 15:34, Jürgen Hestermann wrote: With the following declaration and code: --- var A,B: array of integer; ... SetLength(A,10); B := A; SetLength(B,20); --- both variables A and B point to the same array with 20 Elements. Changing A changes B and vice

Re: [fpc-pascal] Some questions regarding language changes in trunk

2014-02-09 Thread Sven Barth
On 09.02.2014 16:02, leledumbo wrote: This won't have any negative impact on logical expressions I expect that. I suppose the compiler has a mechanism for this such that "if true then" would work. I haven't explicitely checked it nor looked at the code (no time currently), but it should eith

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Sven Barth
On 09.02.2014 15:10, Fred van Stappen wrote: > Date: Sun, 9 Feb 2014 13:08:16 +0100 > From: freepas...@ypa-software.de > To: fpc-pascal@lists.freepascal.org > Subject: Re: [fpc-pascal] High() and Low() for empty dynamic arrays > > Am 09.02.2014 13:05, schrieb Fred van Stappen: > > if leng

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Sven Barth
On 09.02.2014 15:46, Jürgen Hestermann wrote: Am 2014-02-09 15:10, schrieb Fred van Stappen: > > if length(MyArray) > 0 then > > for x := 0 to high(MyArray) do > > MyArray[x].Free; As I have learned just recently ;-) this code could be shortened by for x := low(MyArray) to high(MyArray) d

Re: [fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Flávio Etrusco
On Sun, Feb 9, 2014 at 12:34 PM, Jürgen Hestermann wrote: > (...) > With the following declaration and code: > > --- > var A,B: array of integer; > ... > SetLength(A,10); > B := A; > SetLength(B,20); > --- > > both variables A and B point to the same array with 20 E

Re: [fpc-pascal] Some questions regarding language changes in trunk

2014-02-09 Thread leledumbo
> This won't have any negative impact on logical expressions I expect that. I suppose the compiler has a mechanism for this such that "if true then" would work. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Some-questions-regarding-language-changes-in-trunk-

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Jürgen Hestermann
Am 2014-02-09 15:10, schrieb Fred van Stappen: > > if length(MyArray) > 0 then > > for x := 0 to high(MyArray) do > > MyArray[x].Free; As I have learned just recently ;-) this code could be shortened by for x := low(MyArray) to high(MyArray) do MyArray[x].Free; if x is a signed integer. S

[fpc-pascal] Dynamic arrays, yet another pitfall

2014-02-09 Thread Jürgen Hestermann
There is another possible pitfall with dynamic arrays I trapped into which I would like to share. Those who handle dynamic arrays in a virtuoso manner daily may skip this posting of course. But I think for those who never used them before it may be of use. Maybe it can be added to the Wiki (alth

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Fred van Stappen
> Date: Sun, 9 Feb 2014 13:08:16 +0100 > From: freepas...@ypa-software.de > To: fpc-pascal@lists.freepascal.org > Subject: Re: [fpc-pascal] High() and Low() for empty dynamic arrays > > Am 09.02.2014 13:05, schrieb Fred van Stappen: > > if length(MyArray) > 0 then > > for x := 0 to high(MyArray

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Michael Fuchs
Am 09.02.2014 13:05, schrieb Fred van Stappen: > if length(MyArray) > 0 then > for x := 0 to high(MyArray) do > MyArray[x].Free; > > But, if i use : > > setlength(MyArray, 0) ; > > would it do the same job ? No. Your array contains only references to the objects. The references where del

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Fred van Stappen
Hello everybody. I have a question (maybe stupid) about dynamic arrays... Usually, before to close the application, to avoid memory leak, i do : if length(MyArray) > 0 then for x := 0 to high(MyArray) do MyArray[x].Free; But, if i use : setlength(MyArray, 0) ; would it do the same job ?

Re: [fpc-pascal] fp universal library ?

2014-02-09 Thread Fred van Stappen
Hello everybody. Here next episode of the conversion of a useful fp unit into a universal library... After a hard battle, ... i win. But mainly because of the extremely high quality of fpc. The compiler gives me useful tips to realise that unique library. Unique because that dynamic loaded

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Saunders, Rich
On 2014-02-09 04:11, Jürgen Hestermann wrote: Am 2014-02-08 19:53, schrieb Florian Klämpfl: You didn't have only a question but you made also a proposal for a language change. And when proposing a change it is very usefull to have an example which demonstrates the reason for the change. [sni

Re: [fpc-pascal] Some questions regarding language changes in trunk

2014-02-09 Thread Sven Barth
On 09.02.2014 03:48, leledumbo wrote: http://wiki.freepascal.org/User_Changes_Trunk#Comparative_operators_can_have_any_result_type Is this a preparation for LINQ-like functionality? Delphi compatibility. But as the example shows you could use it for LINQ-like functionality as well. htt

Re: [fpc-pascal] High() and Low() for empty dynamic arrays

2014-02-09 Thread Jürgen Hestermann
Am 2014-02-08 19:53, schrieb Florian Klämpfl: > You didn't have only a question but you made also a proposal for a > language change. And when proposing a change it is very usefull to have > an example which demonstrates the reason for the change. What code should I have written? I was convinced