Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-20 Thread Richard Ward
On Jun 20, 2009, at 6:00 AM, David Noon wrote: I think it is more expressive to make the semantics clear by declaring an inconstant constant as a variable -- because that's what it is -- This semantic issue is very confusing for beginners including people who are migrating from a non

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-20 Thread David W Noon
On Sat, 2009-06-20 at 18:31 +0200, Jürgen Hestermann wrote: Richard Ward schrieb: In my opinion also, the semantics should be changed to reflect the actual nature of the construct and behavior. Agree. I think Richard Ward actually meant the syntax, not the semantics. The

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-19 Thread Martin Friebe
Jürgen Hestermann wrote: Paul Nicholls schrieb: I also find writable constants hand for things like this where I can define the 'variable' + values too so I don't have to set the values at run time: But can't you do the same with a variable declaration? If you want to change the value at

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-19 Thread Graeme Geldenhuys
Martin Friebe wrote: The const version act like a global variable. It is set to 1 once at some time before the 1st call to Foo. It will not be initialized again. If Foo chages it, it will keep the changed value, even between calls to Then this is a language issue. 'const' is clearly not the

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-19 Thread Jürgen Hestermann
The var version, acts as if your first statement in the procedure was a:= 1;. It initializes the variable each time you enter the function. If you enter the function recursively, then each level, has it's own a, not touching the value of the callers a I also used Borlands const-hack a lot.

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-19 Thread David W Noon
On Fri, 2009-06-19 at 18:35 +0200, Jürgen Hestermann wrote: The var version, acts as if your first statement in the procedure was a:= 1;. It initializes the variable each time you enter the function. If you enter the function recursively, then each level, has it's own a, not touching

[fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
Hi, Recently I learned that you can have writeable typed constants. That sounds rather like an oxymoron to my. Writeable constants make no sense, is that then simply a variable? What is the use of a writeable typed constant? Below is two examples of how they can be used, and support for them are

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Vincent Snijders
Graeme Geldenhuys schreef: Hi, Recently I learned that you can have writeable typed constants. That sounds rather like an oxymoron to my. Writeable constants make no sense, is that then simply a variable? What is the use of a writeable typed constant? Backwards compatibility with turbo

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
Vincent Snijders wrote: Backwards compatibility with turbo pascal, which lacked initialized variables and writable constants were the alternative. Thanks Vincent. The Kylix 3 help mentioned early versions of Delphi and Borland Pascal, which made me think that it must have been some limitation

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread fpclist
On Thursday 18 June 2009 08:51:13 Vincent Snijders wrote: Graeme Geldenhuys schreef: Hi, Recently I learned that you can have writeable typed constants. That sounds rather like an oxymoron to my. Writeable constants make no sense, is that then simply a variable? What is the use of a

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
fpcl...@silvermono.co.za wrote: Is this likely to be dropped in future versions of FPC? No idea. But I have noticed that FPC (mode objfpc) defaults to allow writeable typed constants, whereas Delphi and Kylix doesn't. In the latter two compilers you have to enable is support with $J+ compiler

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
I don't know (have not tested) what FPC does with mode delphi though. OK, just tested FPC modes objfpc and delphi. In both cases writeable typed constants are allow by default. This is not compatible with current Delphi compilers. I still think this should be disable by default in both

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread fpclist
On Thursday 18 June 2009 10:48:57 Graeme Geldenhuys wrote: I don't know (have not tested) what FPC does with mode delphi though. But seeing that this feature is just for backward compatibility, maybe it should be disallowed by default in mode objfpc as well? It also works in Delphi mode.

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Vincent Snijders
Graeme Geldenhuys schreef: I don't know (have not tested) what FPC does with mode delphi though. OK, just tested FPC modes objfpc and delphi. In both cases writeable typed constants are allow by default. This is not compatible with current Delphi compilers. I still think this should be

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
Vincent Snijders wrote: I disagree. It would be backwards incompatible with existing objfpc programs. That decision should have been made 10 (?) years ago, when mode objfpc was introduced. Not everything was done correctly 10 years ago (or first time round). There are many bug reports still

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Florian Klaempfl
Graeme Geldenhuys schrieb: Vincent Snijders wrote: I disagree. It would be backwards incompatible with existing objfpc programs. That decision should have been made 10 (?) years ago, when mode objfpc was introduced. Not everything was done correctly 10 years ago (or first time round).

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread fpclist
It's intersting to note that as far back as Delphi 5,(oldest I have on my system), attempting to write to a typed constant causes a left side cannot be assigned to compiler error. I guess as long as FPC compiler offers TP7 compatibility, this feature must be retained. Also, bear in mind that

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Marco van de Voort
In our previous episode, Florian Klaempfl said: Not everything was done correctly 10 years ago (or first time round). Nevertheless, writable typed constants are simply an important part of Borland style Object Pascal. Is it, since D4 also supports var? I agree it is a sterile difference,

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
Florian Klaempfl wrote: Nevertheless, writable typed constants are simply an important part of Borland style Object Pascal. I'm not arguing that. Then maybe writeable typed constants should be disabled for compiler mode delphi at least. It's a Delphi compatibility issue after all. Just this

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Martin Friebe
Graeme Geldenhuys wrote: FPC often implements something that breaks existing code. Examples :)? Please note that I am not saying I disagree with the changes. I know they were introduced for the better. What I am saying, is that changes do get introduced into FPC (for whatever

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Graeme Geldenhuys
Martin Friebe wrote: Afaik 1 3 are the same? True. And if I understand the changes where mad, because this feature was broken before: To quote myself, even though I know one shouldn't. ;-) I know they were introduced for the better. I was not arguing the point that those changes

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Paul Nicholls
2009/6/18 Graeme Geldenhuys grae...@opensoft.homeip.net Vincent Snijders wrote: Backwards compatibility with turbo pascal, which lacked initialized variables and writable constants were the alternative. Thanks Vincent. The Kylix 3 help mentioned early versions of Delphi and Borland

Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-18 Thread Jürgen Hestermann
Paul Nicholls schrieb: I also find writable constants hand for things like this where I can define the 'variable' + values too so I don't have to set the values at run time: But can't you do the same with a variable declaration? If you want to change the value at runtime it's definitely