Sujet : Re: oo::class - my variable vs variable
De : mark (at) *nospam* qtrac.eu (Mark Summerfield)
Groupes : comp.lang.tclDate : 06. Jul 2024, 09:54:38
Autres entêtes
Message-ID : <tZKcnTx2o7DTmxT7nZ2dnZfqnPGdnZ2d@brightview.co.uk>
References : 1 2
User-Agent : Pan/0.149 (Bellevue; 4c157ba)
On Fri, 5 Jul 2024 22:26:16 +0200, Schelte wrote:
[snip]
So, in the constructor of your example I would use "variable", while I'd
use "my variable" in the methods:
oo::class create P {
constructor {{x 0} {y 0}} {
variable x_ $x y_ $y
}
method x {} {
my variable x_
return $x_
}
}
What I still don't understand is that in method x, _both_ "my variable"
_and_ plain "variable" seem to work.
In fact the only time I've needed "my" so far is in a method call. (But
I'll read the web page that was recommended and am still working my way
through reading Tip 257.)