> 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
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 va
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
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
> 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 th
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
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 ?
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
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
Am 08.02.2014 18:06, schrieb Jürgen Hestermann:
>
> Am 2014-02-08 17:40, schrieb Florian Klaempfl:
>>
>>> You mean I should post thousands of code lines?
>>
>> Of course not, just a small example as I did.
>>
>
> But for what reason?
> It just generates work without benefit.
>
> If I had doubts
Am 08.02.2014 18:06 schrieb "Jürgen Hestermann" :
>
>
> Am 2014-02-08 17:40, schrieb Florian Klaempfl:
>
>>
>>> You mean I should post thousands of code lines?
>>
>>
>> Of course not, just a small example as I did.
>>
>
> But for what reason?
> It just generates work without benefit.
>
> If I had d
Am 2014-02-08 17:40, schrieb Florian Klaempfl:
You mean I should post thousands of code lines?
Of course not, just a small example as I did.
But for what reason?
It just generates work without benefit.
If I had doubts about my assumption regarding High and Low
I would not have asked my q
Am 08.02.2014 17:35, schrieb Jürgen Hestermann:
> Unfortunatly you posted not a complete example which shows the
behaviour but only uncompilable code snippts.
> Post always complete examples when discussing strange behaviour.
You mean I should post thousands of code lines?
Of course not, ju
On Sat, 8 Feb 2014, leledumbo wrote:
Here:
var MyArray : array of longint;
begin
writeln(low(MyArray));
writeln(high(MyArray));
end.
prints
0
-1
Is this (High() on empty dynamic arrays return -1) documented somewhere?
It is now, in the system unit documentation for the High() fun
Am 2014-02-08 17:05, schrieb Florian Klaempfl:
> Here:
> var MyArray : array of longint;
> begin
> writeln(low(MyArray));
> writeln(high(MyArray));
> end.
> prints
> 0
> -1
Hmm.
I was under the impression that both give back zero.
But you are right.
A closer look showed that the error I got f
> Here:
>
> var MyArray : array of longint;
>
> begin
>writeln(low(MyArray));
>writeln(high(MyArray));
> end.
>
> prints
>
> 0
> -1
Is this (High() on empty dynamic arrays return -1) documented somewhere?
--
View this message in context:
http://free-pascal-general.1045716.n5.nabble
Am 08.02.2014 16:56, schrieb Jürgen Hestermann:
because otherwise I would get an error in case the length is 0
because Low() and High() both give back 0.
The result of both functions is the same as if the array had exact one
element.
Here:
var MyArray : array of longint;
begin
writeln(low(
Some time ago there was a discussion about the data type
given back by the "length" function.
Several reasons were given for the type beeing a *signed* integer.
But what about High() and Low()?
Shouldn't they give back signed integers too for the same reasons?
Especially, when I have a dynamic a
18 matches
Mail list logo