On Fri, 16 Jun 2017, PICCORO McKAY Lenz wrote: > tested was a cache doc problem maybe.. thanks ... > > i now understand clarelly about class using static and private.. but for > variables: > wiki was: > "If the static keyword is specified, the same variable will be shared with > every object of this class." > > well seems "Public var" and "Static public var" are equal and there's no > difference? so where are the logic with public static? > > please iluminate me... >
"Public" or "Private" control the visibility of a symbol, whereas "Static" (or leaving out "Static") controls the storage type of the variable. A static variable is stored in the *class* and shared by all objects. If you modify a static variable from one object, it will change for all objects. This is orthogonal to visibility. You can combine Static with Public or Private. Neither implies the other. You should be familiar with this concept if you know Java and PHP. It's about the same there, although I don't think Gambas has static local variables, which is another place where the word "static" is used in those languages. In case you are confused because "Static" appears in two places (the CREATE STATIC flag for classes and the STATIC keyword for variable/ property/method declaration), those two things aren't necessarily related. For example, CREATE PRIVATE has no relation to private variable declaration (where you also use PRIVATE) and no relation to the CREATE flag you specify with the OPEN instruction for files. It's just that those two words "CREATE" and "PRIVATE" already exist in Gambas and they together kind of convey the meaning of "CREATE PRIVATE", namely that you can't create objects of the class using NEW. Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user