On Fri, 4 Apr 2003, Anton Tichawa wrote:
> On Friday 04 April 2003 07:48, you wrote: > > > Hello! > > > > > >> Can any tell me if there's "Class Variable" in free pascal like in > > >> java? > > >> I mean, in java, you can declare a class memeber to be "static", all > > >> instance of this class share the same variable memory. Such a member can > > >> be > > >> accessed through class name without any instantiation. > > >> Does free pascal will add such a feature in the future? > > > > > > AFAIK, class variables are not supported yet, nor are class properties. > > > But > > > it's possible to use class methods, which in turn access a global > > > variable. > > > > Sorry that is wrong, static class members are supported, you need to > > enable the static keyword using -St > > > > I don't know what you mean with class properties. > > Sorry for my misinfo, but I didn't find anything about class variables in the > docs (1.06), and I tried, in vain, to compile programs with class variables. I think peter was wrong. He meant class functions or methods. > I'm happy to learn that -St allows using class variables. It's a pity, > though, that different keywords have to be used for class variables and class > methods. > > By class properties, I mean properties that only access class members (class > variables and class methods), and are accessible with the syntax: > > <classtype>.<propertyname>. > > When trying class methods, I found that the executable behaves strange: > Invoking a class method with > > <classtype>.<method> > > works fine. But, invoking the class method with > > <classvar>.<method> > > is accepted by the compiler, but results in an exception when <classvar> is > nil. Is that OK? It depends on what you do in this method. It definitely works, because e.g. 'Classname' is a class method. The idea of a class variable is strange to me. Why not simply use a global variable ? Michael. _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal