Re: oo::class - my variable vs variable

Liste des GroupesRevenir à cl tcl 
Sujet : Re: oo::class - my variable vs variable
De : mark (at) *nospam* qtrac.eu (Mark Summerfield)
Groupes : comp.lang.tcl
Date : 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.)




Date Sujet#  Auteur
4 Jul 24 * oo::class - my variable vs variable7Mark Summerfield
5 Jul 24 +- Re: oo::class - my variable vs variable1Petro Kazmirchuk
5 Jul 24 +- Re: oo::class - my variable vs variable1greg
6 Jul 24 +* Re: oo::class - my variable vs variable2Mark Summerfield
7 Jul 24 i`- Re: oo::class - my variable vs variable1et99
7 Jul 24 `* Re: oo::class - my variable vs variable2greg
7 Jul 24  `- Re: oo::class - my variable vs variable1et99

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal