From: Fredrik Karlsson on
Hi,

I am having troubles defining a "variable" method in a class (in order
to agree with an old API in a new implementation) and I got very
strange errors. I guess it would have to do with "variable" already
being implemented for oo::class or something similar.. but is there
any way around this?

/Fredrik
From: Fredrik Karlsson on
On Mar 25, 8:55 pm, Fredrik Karlsson <dargo...(a)gmail.com> wrote:
> Hi,
>
> I am having troubles defining a "variable" method in a class (in order
> to agree with an old API in a new implementation) and I got very
> strange errors. I guess it would have to do with "variable" already
> being implemented for oo::class or something similar.. but is there
> any way around this?
>
> /Fredrik

Sorry, I meant oo:object, not oo:class.

From: Donal K. Fellows on
On 25 Mar, 19:55, Fredrik Karlsson <dargo...(a)gmail.com> wrote:
> I am having troubles defining a "variable" method in a class (in order
> to agree with an old API in a new implementation) and I got very
> strange errors. I guess it would have to do with "variable" already
> being implemented for oo::class or something similar.. but is there
> any way around this?

Yes, but I'll need to know what you're trying to do more exactly
first. A code example which demonstrates the problem neatly would help
a lot.

Donal.
From: Fredrik Karlsson on
On 26 mar, 11:49, "Donal K. Fellows"
<donal.k.fell...(a)manchester.ac.uk> wrote:
> On 25 Mar, 19:55, Fredrik Karlsson <dargo...(a)gmail.com> wrote:
>
> > I am having troubles defining a "variable" method in a class (in order
> > to agree with an old API in a new implementation) and I got very
> > strange errors. I guess it would have to do with "variable" already
> > being implemented for oo::class or something similar.. but is there
> > any way around this?
>
> Yes, but I'll need to know what you're trying to do more exactly
> first. A code example which demonstrates the problem neatly would help
> a lot.
>
> Donal.

Hi,

In the end I found that what I thought was caused by me defining a
"variable" method was in cfact caused by something different. I was
just fooled by the error message.

On a related note, where do I get good information concerning the
differnce between "my variable" and "variable" in TclOO. When and why
should you use the two versions?

/Fredrik
From: Donal K. Fellows on
On 31 Mar, 13:10, Fredrik Karlsson <dargo...(a)gmail.com> wrote:
> On a related note, where do I get good information concerning the
> differnce between "my variable" and "variable" in TclOO. When and why
> should you use the two versions?

Usually inside a method you can use either. If you're wanting the
standard Tcl [variable] command's (to my mind) odd assignment rules,
then use it. If you want the (IMO) much more sensible rules that you
get with something like [global], then [my variable] is better. :-)

The one time when you *need* the [my variable] is when you've exposed
it (with an 'export' declaration) and are using it from somewhere
other than the object's methods. At that point, [my variable] works
easily when the other alternatives are horrendous hacks.

Donal.