Re: [fpc-pascal] readonly variables

2009-12-02 Thread Holger Bruns
Anthony Walter schrieb: This first time concerning the topic const records passed incorrectly you said, It is nowhere written in the Delphi specs that const parameters are passed by reference. It is often so, but is by no means guaranteed I checked this out. Both Turbo Pascal and fpc

Re: [fpc-pascal] readonly variables

2009-12-02 Thread Jonas Maebe
On 02 Dec 2009, at 10:26, Holger Bruns wrote: I checked this out. Both Turbo Pascal and fpc reported the same error massage: Variable identifier expected. You simply cannot pass constant values by reference. Passing a parameter by reference and var parameters are not the same thing.

Re: [fpc-pascal] readonly variables

2009-11-30 Thread Marco van de Voort
In our previous episode, Anthony Walter said: Allows is not the same as forces. This line in the help file does not say that const parameters are passed by reference. It says that it may often be so, perhaps all current implementations make it so, but it is by no means guaranteed.

Re: [fpc-pascal] readonly variables

2009-11-30 Thread Jonas Maebe
On 30 Nov 2009, at 10:29, Marco van de Voort wrote: In our previous episode, Anthony Walter said: Martin Schreiber also chimed in, pointing out: http://bit.ly/6uaAiB Larger sets, records, and static arrays are passed as 32-bit pointers to the value. The documentation is unambiguous

Re: [fpc-pascal] readonly variables

2009-11-30 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: anything to say on the subject is patently false. As per what? OS ABI? Delphi rules? As per the linked Delphi documentation. But as has mentioned before, the Delphi documentation doesn't match its implementation in case of cdecl and const

Re: [fpc-pascal] readonly variables

2009-11-30 Thread Flávio Etrusco
On Sun, Nov 29, 2009 at 1:11 PM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: On 29 Nov 2009, at 16:51, Anthony Walter wrote: Having said all that, Jonas, what is the actual implemented behaviour of FPC? Does it 0 initialize heap memory at startup or not? I guess you mean global data rather

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Ivo Steinmann
Anthony Walter schrieb: I don't care if you claim to have written documentation, you clearly either don't have a grasp of the English language, good memory, research skills, or some combination those deficiencies. Michael and so Jonas are Authors and Developers of FPC. Most FPC Authors are

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Bart
Can we please not start bashing people here? (Cuuntry of origin: Netherlands, so not a native English speaker as well) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Florian Klaempfl
Anthony Walter schrieb: Okay, I am going to call bullshit on you. What about just unsubscribing from the list? Nobody needs you here. MvC did an incredible job on FPC docs, you just waste our time. ___ fpc-pascal maillist -

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Mehmet Erol Sanliturk
Florian Klaempfl wrote: Anthony Walter schrieb: Okay, I am going to call bullshit on you. What about just unsubscribing from the list? Nobody needs you here. MvC did an incredible job on FPC docs, you just waste our time. Actually it is a very ridiculous behavior to talk about developers

Re: [fpc-pascal] readonly variables

2009-11-29 Thread patspiper
Anthony Walter wrote: Okay, I am going to call bullshit on you. I, like many others in this list, resent your unwarranted behavior towards Michael Van Canneyt. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jonas Maebe
On 28 Nov 2009, at 22:34, Michael Van Canneyt wrote: It was Jonas Maebe (Jonas, correct me if I'm wrong) who pointed out (already some time ago) that this behaviour is purely coincidental (but admittedly convenient), and should not be taken for granted. That's correct, Usually, this is

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Xgelb
Hi Jürgen, Not that I am aware of. But for what reason do you want such a behaviour? I wrote data analysis programs which are very difficult. I change some lines to optimize a program. Somethimes it is necessary that I will save a variable after an input because the second setup of the variable

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jonas Maebe
On 28 Nov 2009, at 23:31, Anthony Walter wrote: This second time regarding the current discussion you said: This is not guaranteed in any way. and nowhere it says in the Pascal language specification that this is guaranteed by the compiler And I responded with the section, subsection, page

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Anthony Walter
Jonas, Thank you. I certainly will make an attempt to tone down a few of my remarks which I admit were inflammatory. I assure everyone here though, my purpose in conversing on these lists is to help improve FPC, so far by discussing easy to resolve and reproduce technical points. I personally

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Micha Nelissen
Anthony Walter wrote: Having said all that, Jonas, what is the actual implemented behaviour of FPC? Does it 0 initialize heap memory at startup or not? If not, what is the justification for not doing so when this has been a long established behaviour of Delphi? It's not the compiler or RTL

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jonas Maebe
On 29 Nov 2009, at 16:51, Anthony Walter wrote: Having said all that, Jonas, what is the actual implemented behaviour of FPC? Does it 0 initialize heap memory at startup or not? I guess you mean global data rather than heap (heap is what is handled by getmem/freemem/..., and there are no

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Anthony Walter
FPC currently initialises the global data to 0 on platforms that do not do this by themselves. When it turns global variables into register variables, it will also initialise such registers with 0. Ah, okay. So it is working as expected. Thanks for the reply.

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Michael Van Canneyt
On Sun, 29 Nov 2009, Anthony Walter wrote: Jonas, Thank you. I certainly will make an attempt to tone down a few of my remarks which I admit were inflammatory. I assure everyone here though, my purpose in conversing on these lists is to help improve FPC, so far by discussing easy to resolve

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Mehmet Erol Sanliturk
Micha Nelissen wrote: Anthony Walter wrote: Having said all that, Jonas, what is the actual implemented behaviour of FPC? Does it 0 initialize heap memory at startup or not? If not, what is the justification for not doing so when this has been a long established behaviour of Delphi? It's not

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jonas Maebe
On 29 Nov 2009, at 19:20, Mehmet Erol Sanliturk wrote: My experience with Windows XP Professional is that it is NOT zeroing the memory . I know this from actual Delphi ( and also Free Pascal ) compiled program executions . Due to this I am explicitly initializing all of the local simple

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Mehmet Erol Sanliturk
Jonas Maebe wrote: On 29 Nov 2009, at 19:20, Mehmet Erol Sanliturk wrote: My experience with Windows XP Professional is that it is NOT zeroing the memory . I know this from actual Delphi ( and also Free Pascal ) compiled program executions . Due to this I am explicitly initializing all of

Re: [fpc-pascal] readonly variables

2009-11-29 Thread M Pulis
On Nov 28, 2009, at 1:15 PM, Anthony Walter wrote: This is not guaranteed in any way. It happens to be so most of the time, but your code should never assume this is so, except for global Ansistring variables. If all globals weren't initialized to 0 a lot of code from lots of people

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Frank Peelo
Anthony Walter wrote: Okay, I am going to call bullshit on you. This is the second time (in a few weeks) where you've replied to something I've written with wrong information. This first time concerning the topic const records passed incorrectly you said, It is nowhere written in the Delphi

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jonas Maebe
On 29 Nov 2009, at 22:59, Anthony Walter wrote: Do you mean this one? Using const allows the compiler to optimize code for structured- and string-type parameters. Allows is not the same as forces. This line in the help file does not say that const parameters are passed by reference. It

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Anthony Walter
So it seems that passing them by value actually corresponds to what the Delphi docs say. Jonas, I agree, the documentation definitely does address the issue, which was where that conversation was derailed. Regarding actual implementation, I previously posted the full source to a test program

Re: [fpc-pascal] readonly variables

2009-11-29 Thread Jorge Aldo G. de F. Junior
This is quite simple : 1 - Imagine that fpc initializes all memory to 0. 2 - Imagine that you are running on a low power platform. 3 - You are not going to use the default value of 0. 4 - You reinitialize the memory to your own default value. See, you did TWO memory store instructions instead of

[fpc-pascal] readonly variables

2009-11-28 Thread Markus Glugla
Hello, is it possible to set a variable in a programm as a readonly variable? I would set a variable at a position in the runing programm. Since this time the variable should be readonly. The next set of the variable should produce an error. In bash programming you found a command readonly

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Jürgen Hestermann
is it possible to set a variable in a programm as a readonly variable? Not that I am aware of. But for what reason do you want such a behaviour? And if I think it over, this can only work at runtime (letting the program crash on the second assignment). At compile time the compiler may not

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Mattias Gaertner
On Sat, 28 Nov 2009 14:58:26 +0100 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: is it possible to set a variable in a programm as a readonly variable? Not that I am aware of. But for what reason do you want such a behaviour? And if I think it over, this can only work at runtime

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Howard Page-Clark
On Sat, 28 Nov 2009 15:07:42 +0100 Mattias Gaertner nc-gaert...@netcologne.de wrote: On Sat, 28 Nov 2009 14:58:26 +0100 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: is it possible to set a variable in a programm as a readonly variable? Use the following: property MyVar: integer

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Aleksa Todorovic
You can use read function: var DirectAccessToValue: T; function Value: T; inline; begin Result := DirectAccessToValue; end; begin ... DirectAccessToValue := ...; ... DoSomething(Value); end. On Sat, Nov 28, 2009 at 13:55, Markus Glugla f...@xgelb.de wrote: Hello, is it possible

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Anthony Walter
procedure InitMyVariable(Value: T); function MyVariable: T; implementation var PrivateMyVariable: T; PrivateMyVariableSet: Boolean; procedure InitMyVariable(Value: T); begin if not PrivateMyVariableSet then PrivateMyVariable := Value; PrivateMyVariableSet := True; end; function

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Howard Page-Clark
On Sat, 28 Nov 2009 12:10:48 -0500 Anthony Walter sys...@gmail.com wrote: procedure InitMyVariable(Value: T); function MyVariable: T; implementation var PrivateMyVariable: T; PrivateMyVariableSet: Boolean; procedure InitMyVariable(Value: T); begin if not PrivateMyVariableSet

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Anthony Walter
PrivateMyVariableSet is not intialised, so will have an undefined (random) value when InitMyVariable is first called. Mattias' code given earlier avoids this problem. Bzzzt. Wrong. Global variables (even in the implementation section) are always initialized to 0.

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Michael Van Canneyt
On Sat, 28 Nov 2009, Anthony Walter wrote: PrivateMyVariableSet is not intialised, so will have an undefined (random) value when InitMyVariable is first called. Mattias' code given earlier avoids this problem. Bzzzt. Wrong. Global variables (even in the implementation section) are always

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Anthony Walter
This is not guaranteed in any way. It happens to be so most of the time, but your code should never assume this is so, except for global Ansistring variables. If all globals weren't initialized to 0 a lot of code from lots of people would potentially be in trouble. I've been using

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Michael Van Canneyt
On Sat, 28 Nov 2009, Anthony Walter wrote: This is not guaranteed in any way. It happens to be so most of the time, but your code should never assume this is so, except for global Ansistring variables. If all globals weren't initialized to 0 a lot of code from lots of people would

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Anthony Walter
That should be removed, actually. I'll take that as an admission that you were wrong. It's in the specification, lot's of code uses the feature, and it works the way I described. Changing the specification to match your argument is stupid. ___

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Michael Van Canneyt
On Sat, 28 Nov 2009, Anthony Walter wrote: That should be removed, actually. I'll take that as an admission that you were wrong. It's in the specification, lot's of code uses the feature, and it works the way I described. I'm not admitting anything here, I am attempting to enlighten you

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Anthony Walter
Okay, I am going to call bullshit on you. This is the second time (in a few weeks) where you've replied to something I've written with wrong information. This first time concerning the topic const records passed incorrectly you said, It is nowhere written in the Delphi specs that const

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Andrew Hall
Michael - I see you are one of the authors of fpc (thank you), so I assume your statement is true by virtue of inside knowledge. But this is a concern. As I'm sure you will know, in Delphi globals are always initialised to zero - and in my experience (almost 15 years with a 30-strong Delphi