Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Jürgen Hestermann
Am 2016-06-26 um 01:19 schrieb Karoly Balogh (Charlie/SGR): > No. Local variables are not initialized by default. Managed type or not, > doesn't make a difference. This is not true. Local variables of managed types are of course initialized! If you declare var S : String; then it is of course

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Karoly Balogh (Charlie/SGR)
Hi, On Sun, 26 Jun 2016, Jürgen Hestermann wrote: Ok, scrap what I wrote before... :| You are right about the managed types initialization. But then the documentation needs to be corrected there too. But actually, result is not a local var, but in fact a "special" parameter of the function. My

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Martin Schreiber
On Sunday 26 June 2016 12:09:58 Jc3bcrgen Hestermann wrote: > > The only exception (at least since FPC 3) is the function result > which is totally unexpected. > Why such an exception? > I don't think one could treat a function result as a normal local variable. The reason why not to initialise

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread C Western
On 26/06/16 11:09, Jürgen Hestermann wrote: Am 2016-06-26 um 01:19 schrieb Karoly Balogh (Charlie/SGR): No. Local variables are not initialized by default. Managed type or not, doesn't make a difference. This is not true. Local variables of managed types are of course initialized! If you

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Sven Barth
Am 26.06.2016 12:10 schrieb "Jürgen Hestermann" : > > Am 2016-06-26 um 01:19 schrieb Karoly Balogh (Charlie/SGR): > > No. Local variables are not initialized by default. Managed type or not, > > doesn't make a difference. > > This is not true. > Local variables of

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Jürgen Hestermann
Am 2016-06-26 um 14:13 schrieb Sven Barth: > But also no word that it is true either, cause you're not declaring a variable for the Result. Of course I am declaring a variable: function X : String; Now the (local) variable "Result" is of type "String". I use it in the same way as any other

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Dimitrios Chr. Ioannidis
Hi, On 26/6/2016 7:20 μμ, Jürgen Hestermann wrote: And because it is a manged type I could rely on the documentation which says that managed types are initialized (with zero length/nil). "Result" is used in the same way as a (local) variable. What should make me think that it is different? as

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Jürgen Hestermann
Am 2016-06-26 um 14:27 schrieb Karoly Balogh (Charlie/SGR): > There's no exception. At least not specifically for Result. It is simply > variable passed by reference from the caller side, therefore it's not > initialized inside the function. You mean when I have the following:

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Karoly Balogh (Charlie/SGR)
Hi, On Sun, 26 Jun 2016, Jürgen Hestermann wrote: > Am 2016-06-26 um 14:27 schrieb Karoly Balogh (Charlie/SGR): > > There's no exception. At least not specifically for Result. It is simply > > variable passed by reference from the caller side, therefore it's not > > initialized inside the

Re: [fpc-pascal] reference-counted function results not initialized to nil

2016-06-26 Thread Sven Barth
On 26.06.2016 18:20, Jürgen Hestermann wrote: > Am 2016-06-26 um 14:13 schrieb Sven Barth: >> But also no word that it is true either, cause you're not declaring a > variable for the Result. > > Of course I am declaring a variable: > > function X : String; > > Now the (local) variable "Result"

Re: [fpc-pascal] which "managed" result types require extra work?

2016-06-26 Thread David Emerson
Addendum - what about a return value which is a class that implements an interface? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] which "managed" result types require extra work?

2016-06-26 Thread Jonas Maebe
David Emerson wrote: > Which types do we need to initialize to null/nil/zero/'' when they are a > function result? Results of all types (managed or not) need to be set to "empty" if you want them to return an "empty" result. > I understand COM-style interfaces are also managed types, do they

[fpc-pascal] which "managed" result types require extra work?

2016-06-26 Thread David Emerson
Okay, making a new thread here, to ask one question: Which types do we need to initialize to null/nil/zero/'' when they are a function result? - dynamic arrays - ansistring - unicodestring - string, with {$H+} (but not string[length]) - records containing any of them - anything else??? I

Re: [fpc-pascal] which "managed" result types require extra work?

2016-06-26 Thread Dimitrios Chr. Ioannidis
On 27/6/2016 3:55 πμ, David Emerson wrote: Okay, making a new thread here, to ask one question: Which types do we need to initialize to null/nil/zero/'' when they are a function result? - dynamic arrays - ansistring - unicodestring - string, with {$H+} (but not string[length]) - records