[Gambas-user] Re Issue 169 - a few comments

Bruce Bruen bbruen at ...2308...
Wed Dec 28 02:11:38 CET 2011


Hi emil.len... at ...626...

I have some thoughts on this.

Static Public Const c As Integer
Any (public) const could be defineable as being "static" by nature (all
instances share the same value).  The Static keyword for Const is not
required and is not in the systax defined in the help for "Constant
Declaration". So a Static Const is the same as a nonstatic const.
If anything the compiler should complain about the word Static being
included in a Const declaration.

Static Public v As Integer
I don't see any reason why a dynamic reference to a static variable
should not be allowed.  It's just referencing the class level instance
of the variable.  From the help on "Variable Declaration" we get "If the
STATIC keyword is specified, the same variable will be shared with every
object of this class."  The Static keyword implies that there will be
only one instance of that variable accessable by all instances of the
class.  There is no restriction of access being limited.

Static Public Sub f()
Now, here is where "Static" means something different to the above!
Static when applied to a method infers that it can only access "the
static variables of the class."  In fact it has a larger meaning in that
it acts only on the class level "instance" (i.e. the "instance" created
when the class is loaded).  The reason for the restriction of access
referencing to only via the class reference is less clear.  I cannot
think of an example at present (sitting in an airport internet cafe) but
suffice to say that the meaning of the Static keyword here differs from
the above.

Static Property p As Integer
This is similar to the above.  A property "really" is one or two
accessor methods.  In that light, they are the same as the "f" method
above.

regards 
Bruce




More information about the User mailing list