Re: [fpc-pascal] Const params question

2017-10-11 Thread Sven Barth via fpc-pascal
Am 11.10.2017 15:28 schrieb "Ryan Joseph" : > > > > > On Oct 11, 2017, at 5:01 PM, Michael Van Canneyt wrote: > > > > No, you need constref then. > > Ok, so constref/var are the same in terms of copying. The docs say const reduces stack size? I never label my parameters with const but maybe it’s w

Re: [fpc-pascal] Const params question

2017-10-11 Thread Ryan Joseph
> On Oct 11, 2017, at 5:01 PM, Michael Van Canneyt > wrote: > > No, you need constref then. Ok, so constref/var are the same in terms of copying. The docs say const reduces stack size? I never label my parameters with const but maybe it’s worth it some cases. Regards, Ryan Joseph

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 9:33 AM, wrote: > On 11/10/17 13:11, Michael Van Canneyt wrote: >> >> Delphi has recently > > > Huh? I thought Delphi got shut down years ago. See https://www.embarcadero.com/products/delphi Marcos Douglas ___ fpc-pascal maill

Re: [fpc-pascal] Const params question

2017-10-11 Thread pascalX
On 11/10/17 13:11, Michael Van Canneyt wrote: Delphi has recently Huh? I thought Delphi got shut down years ago. :? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 9:11 AM, Michael Van Canneyt wrote: > > On Wed, 11 Oct 2017, Marcos Douglas B. Santos wrote: > > [...] >> Is constref compatible with Delphi? > > > Delphi has recently introduced some annotation for the same purpose. > > As usual, they chose to do something different than w

Re: [fpc-pascal] Const params question

2017-10-11 Thread Graeme Geldenhuys
On 2017-10-11 12:03, Michael Van Canneyt wrote: It is actually documented: I'm a step ahead. :-) Just after I sent my email, I did actually go check the documentation and read up on it. Thanks for pointing it out though. Regards, Graeme ___ fpc

Re: [fpc-pascal] Const params question

2017-10-11 Thread Michael Van Canneyt
On Wed, 11 Oct 2017, Marcos Douglas B. Santos wrote: On Wed, Oct 11, 2017 at 7:01 AM, Michael Van Canneyt wrote: On Wed, 11 Oct 2017, Ryan Joseph wrote: If you declare a parameter as const does that effectively behave like passing by reference? I have some performance sensitive function

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 7:01 AM, Michael Van Canneyt wrote: > > > On Wed, 11 Oct 2017, Ryan Joseph wrote: > >> If you declare a parameter as const does that effectively behave like >> passing by reference? I have some performance sensitive functions that >> take records as arguments and I don’t w

Re: [fpc-pascal] Const params question

2017-10-11 Thread Michael Van Canneyt
On Wed, 11 Oct 2017, Graeme Geldenhuys wrote: On 2017-10-11 11:36, Michael Van Canneyt wrote: In the case of const, you don't know. The compiler will do as it sees fit. Oh wow, I really didn't know that. snip The difference is that you can assign something to a var parameter, but

Re: [fpc-pascal] Const params question

2017-10-11 Thread Graeme Geldenhuys
On 2017-10-11 11:36, Michael Van Canneyt wrote: In the case of const, you don't know. The compiler will do as it sees fit. Oh wow, I really didn't know that. snip The difference is that you can assign something to a var parameter, but you cannot assign something to a constref. Than

Re: [fpc-pascal] Const params question

2017-10-11 Thread Michael Van Canneyt
On Wed, 11 Oct 2017, Graeme Geldenhuys wrote: On 2017-10-11 11:01, Michael Van Canneyt wrote: No, you need constref then. So for the record In the example given, will const make a copy of the record and constref will pass in the original record (no copy of data)? In the case of const

Re: [fpc-pascal] Const params question

2017-10-11 Thread Graeme Geldenhuys
On 2017-10-11 11:01, Michael Van Canneyt wrote: No, you need constref then. So for the record In the example given, will const make a copy of the record and constref will pass in the original record (no copy of data)? If so, then what's the difference between constref and var? Because it

Re: [fpc-pascal] Const params question

2017-10-11 Thread Michael Van Canneyt
On Wed, 11 Oct 2017, Ryan Joseph wrote: If you declare a parameter as const does that effectively behave like passing by reference? I have some performance sensitive functions that take records as arguments and I don’t want copying to the stack so I’ve been using @ but maybe const is just as

[fpc-pascal] Const params question

2017-10-11 Thread Ryan Joseph
If you declare a parameter as const does that effectively behave like passing by reference? I have some performance sensitive functions that take records as arguments and I don’t want copying to the stack so I’ve been using @ but maybe const is just as good? Thanks. Regards, Ryan Joseph