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

[fpc-pascal] (Generic) Container Classes

2009-11-28 Thread Juha Manninen
Hi, I submitted a TStringHashMap class to CCR. I also created a wiki page: http://wiki.lazarus.freepascal.org/StringHashMap I made a comprehensive demo program for it. It should be good now. I found some hashed list and similar classes from FPC sources (with no documentation) but no hash map

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 paramet

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
> 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. ___ fpc-pas

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 potentiall

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 Pascal/Del

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 in

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 Howard Page-Clark
On Sat, 28 Nov 2009 12:10:48 -0500 Anthony Walter wrote: > procedure InitMyVariable(Value: T); > function MyVariable: T; > > implementation > > var > PrivateMyVariable: T; > PrivateMyVariableSet: Boolean; > > procedure InitMyVariable(Value: T); > begin > if not PrivateMyVariableSet then

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 MyVa

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 wrote: > Hello, > > is it possible to set a v

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Howard Page-Clark
On Sat, 28 Nov 2009 15:07:42 +0100 Mattias Gaertner wrote: > On Sat, 28 Nov 2009 14:58:26 +0100 > Jürgen Hestermann wrote: > > > > is it possible to set a variable in a programm as a readonly variable? > Use the following: > > property MyVar: integer read FMyVar write SetMyVar; > > And in Se

Re: [fpc-pascal] readonly variables

2009-11-28 Thread Mattias Gaertner
On Sat, 28 Nov 2009 14:58:26 +0100 Jürgen Hestermann 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 (letting the program >

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 ex

[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" mak

Re: [fpc-pascal] Interfaces via implements keyword

2009-11-28 Thread Denis Golovan
Hi Andrew On Thu, Nov 26, 2009 at 4:48 AM, Andrew Hall wrote: > 1) Always reference your host class through an interface you know will be > implemented by the host class, therefore calling "as" from this interface > will always find any of the interfaces your class may support. The easiest > wo

Re: [fpc-pascal] private integer is an illegal counter variable

2009-11-28 Thread Jürgen Hestermann
And there are many reasons why there are so many string types nowadays. True. Simply use {mode objfpc}{$h+} like lazarus suggests. I think the root cause of all these problems are generic types. They cause more trouble than they avoid. I would suggest that noone never uses such generic typ