On Wed, 16 May 2018, denisgolovan wrote:
Yes.
That's exactly why I gave that example.
Your method with Move will trigger segfault eventually, so the compiler support
is required to handle it properly.
But compiler support for copying records exists.
What's wrong with simply doing
R2:=R1;
Yes.
That's exactly why I gave that example.
Your method with Move will trigger segfault eventually, so the compiler support
is required to handle it properly.
BR,
Denis
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepasca
I should probably also note that you shouldn't use move with records
that have ansistrings or other dynamically allocated variables in them..
On 5/15/2018 6:49 PM, Alexander Grotewohl wrote:
type
TRec = record
s1:string;
i1:integer;
end;
var
S1,S2:string;
R1,R2:TRec;
begin
S
type
TRec = record
s1:string;
i1:integer;
end;
var
S1,S2:string;
R1,R2:TRec;
begin
S1:='123';
S2:=S1; // lol
R1.s1:='123';
R1.i1:=1;
move(R1, R2, sizeof(TRec));
writeln(R2.s1, ' ', R2.i1);
end.
On 5/15/2018 2:39 PM, denisgolovan wrote:
Well.
"Copy" works for array
On Tue, May 15, 2018 at 7:05 PM, Jonas Maebe wrote:
>> If Frac(x) equals zero, will Int(x) cahnge the bitpattern of x then?
>> (Or: it cannot be gueranteed that this will not be the case?)
>
>
> That cannot be guaranteed.
OK.
Bart
___
fpc-pascal maill
Well.
"Copy" works for arrays only.
Neither strings nor records work.
Tested in pretty old svn rev. 37656
//=
program project1;
{$mode objfpc}{$H+}
type
TRec = record
s1:string;
i1:integer;
end;
var S1,S2:string;
A1,A2:array of in
Am 15.05.2018 um 14:15 schrieb denisgolovan:
> A side note:
>
> I am still wondering why there is no something like "Clone" function to make
> an independent copy of string/array/... ? It's used quite often in practice
> (as we don't have copy-on-write working in all circumstances).
There is. I
On 15/05/18 13:14, Bart wrote:
If Frac(x) equals zero, will Int(x) cahnge the bitpattern of x then?
(Or: it cannot be gueranteed that this will not be the case?)
That cannot be guaranteed.
Jonas
___
fpc-pascal maillist - fpc-pascal@lists.freepasca
On Tue, 15 May 2018, Sven Barth via fpc-pascal wrote:
Torsten Bonde Christiansen schrieb am Di., 15. Mai 2018,
12:03:
Is this a feature, bug or undocumented behaviour?
This is a feature and absolutely by design.
Afair, this was allowed back in Delphi7 (which is where i copied some of
A side note:
I am still wondering why there is no something like "Clone" function to make an
independent copy of string/array/... ? It's used quite often in practice (as we
don't have copy-on-write working in all circumstances).
BR,
Denis
___
fpc-pasc
Bart schrieb am Di., 15. Mai 2018, 13:22:
> On Sun, May 13, 2018 at 3:40 PM, Jonas Maebe wrote:
> > The only proper way is to use something like Math.SameValue(x, int(x)).
>
> B.t.w. the test suite for the new Int() function (win64)
> (
> https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests
Torsten Bonde Christiansen schrieb am Di., 15. Mai 2018,
12:03:
> Is this a feature, bug or undocumented behaviour?
>
This is a feature and absolutely by design.
> Afair, this was allowed back in Delphi7 (which is where i copied some of
> my old code from), but i'm not sure whether it was docu
On Sun, May 13, 2018 at 3:40 PM, Jonas Maebe wrote:
> The only proper way is to use something like Math.SameValue(x, int(x)).
B.t.w. the test suite for the new Int() function (win64)
(https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/tbs/tb0644.pp?view=markup)
uses
47 function SameValue(
On Sun, May 13, 2018 at 3:40 PM, Jonas Maebe wrote:
> The only proper way is to use something like Math.SameValue(x, int(x)).
> Never use equality tests with floating point values, unless you are checking
> for a specific bit pattern (or if you know that the value can always be
> represented exac
On Tue, May 15, 2018 at 12:06 PM, Maciej Izak wrote:
> you can just use :
>
> NewArray := Copy(OldArray);
Mind you, if OldArray is an array of array, Copy() will copy the
reference to the "second" array, not the actal data.
var
a,b: array of array of TSomeType;
SetLength(a, 5, 5);
a[0,0] :=
On 11/05/18 23:59, Benito van der Zander wrote:
after all these discussions about the frac function, what is the best
way to test if there is a fractional part? That is the most common thing
I use frac for
I have always used frac(x) = 0
Is that worse or better than int(x) = x ?
The only p
Am 11.05.2018 um 23:59 schrieb Benito van der Zander:
> Hi,
>
> after all these discussions about the frac function, what is the best way to
> test if there is a
> fractional part? That is the most common thing I use frac for
>
> I have always used frac(x) = 0
>
> Is that worse or better than i
2018-05-14 11:46 GMT+02:00 Torsten Bonde Christiansen :
> SetLength(NewArray, Length(OldArray));
> for i := Low(OldArray) to High(OldArray) do
> NewArray[i] := OldArray[i];
>
you can just use :
NewArray := Copy(OldArray);
looks better ;)
--
Best regards,
Maciej Izak
Hi All.
I just discovered that SetLength(Var S: Array; NewLength: Integer) has
an undocumented (appenrently unlimited number of) overloaded functions.
Any multi dimentional arrays may be sent to SetLength with appropriate
dimension sizes. Making the following possible:
program SetArrayLengt
Hi List.
This i a real newbie question:
I hardly use dynamic array, so I don't know if there is a simpler method
to copying a dynamic interger array than the straigh forward method:
(I need a copy to preseve the current values of OldArray, since OldArray
will change values later in the progr
20 matches
Mail list logo