Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You are sick, twisted and perverted. I like that in a person.


comp / comp.lang.tcl / A suggestion for Tcl 9

SubjectAuthor
* A suggestion for Tcl 9Helmut Giese
+* Re: A suggestion for Tcl 9Rich
|`- Re: A suggestion for Tcl 9Harald Oehlmann
`* Re: A suggestion for Tcl 9Helmut Giese
 `- Re: A suggestion for Tcl 9Harald Oehlmann

1
Subject: A suggestion for Tcl 9
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Tue, 5 Nov 2024 22:24 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: A suggestion for Tcl 9
Date: Tue, 05 Nov 2024 23:24:53 +0100
Organization: ratiosoft
Lines: 22
Message-ID: <ka5lij9qa7jem9e2ina4ndndhot2ju40qh@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 05 Nov 2024 23:25:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="fb101c03b132d1b418bac58536e478ac";
logging-data="1833129"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/InQBZJa7HHf1fE4+WBE/i"
Cancel-Lock: sha1:xIfGbB6ZZnY//XPcWrkYZ7akQPU=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

Hello out there,
currently Tk accepts only _gobal_ variables for widgets which set a
value. I always wondered why it doesn't also accept a fully namespaced
variable, too. Like so:
---
namespace eval ns {
variable someVar ""
} ttk::radiobutton .rad -text "Some text" -variable ::ns::someVar
---
If one demanded that always either a global or a _fully namespaced_
variable had to be supplied it would not cause any ambiguities even
when the above call would have been inside the namespace where the
variable 'someVar' already is defined.
Tcl 9 is the opportunity to introduce incompatibilities - although I
wonder if this even IS an incompatibility: In Tcl 8 a syntax like
-var ::ns::someVar
is not illegal: it just doesn't have any effect while in Tcl 9 it
would. But this is probably a question of language semantics which I
am not qualified to judge.
Comments welcome
Helmut

Subject: Re: A suggestion for Tcl 9
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Tue, 5 Nov 2024 22:34 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: A suggestion for Tcl 9
Date: Tue, 5 Nov 2024 22:34:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <vge6i7$1nnvi$1@dont-email.me>
References: <ka5lij9qa7jem9e2ina4ndndhot2ju40qh@4ax.com>
Injection-Date: Tue, 05 Nov 2024 23:34:48 +0100 (CET)
Injection-Info: dont-email.me; posting-host="feb61258d3e6861f0f7c4289afe3c16e";
logging-data="1826802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ap7JLH3znQCKcUWHJNHLK"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:aubVLlf+QKPrSw1Xkc7NNZ7dCaU=
View all headers

Helmut Giese <hgiese@ratiosoft.com> wrote:
> Hello out there,
> currently Tk accepts only _gobal_ variables for widgets which set a
> value. I always wondered why it doesn't also accept a fully namespaced
> variable, too.

Unless something has changed in 9, Tk has always accepted fully
qualified namespaced variables for Tk widget variables.

I.e.:

$ rlwrap wish
% namespace eval ns {
variable someVar ""
}
% puts $::ns::someVar

% ttk::radiobutton .r1 -text R1 -value R1 -variable ::ns::someVar
.r1
% ttk::radiobutton .r2 -text R2 -value R2 -variable ::ns::someVar
.r2
% pack .r1 .r2 -side top
% puts $::ns::someVar

% # clicks upon r1
% puts $::ns::someVar
R1
% # clicks upon r2
% puts $::ns::someVar
R2
%

The thing is, they do have to be 'fully qualified' (which is something
that is easy to forget).

> In Tcl 8 a syntax like
> -var ::ns::someVar
> is not illegal: it just doesn't have any effect

As I show above, it does. But, for a radio button, you do need to give
each widget a -value or the widget never sets anything into the
variable.

Subject: Re: A suggestion for Tcl 9
From: Harald Oehlmann
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 6 Nov 2024 07:35 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: A suggestion for Tcl 9
Date: Wed, 6 Nov 2024 08:35:51 +0100
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <vgf68m$20qoc$1@dont-email.me>
References: <ka5lij9qa7jem9e2ina4ndndhot2ju40qh@4ax.com>
<vge6i7$1nnvi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 06 Nov 2024 08:35:52 +0100 (CET)
Injection-Info: dont-email.me; posting-host="58818968ca49048fce7799749d0dfb62";
logging-data="2124556"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QplASyvm5tQ81lGwdFsw+"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HZ2/rfQdMcHacnhhFZd1o2K3aRQ=
In-Reply-To: <vge6i7$1nnvi$1@dont-email.me>
Content-Language: en-GB
View all headers

Am 05.11.2024 um 23:34 schrieb Rich:
> Helmut Giese <hgiese@ratiosoft.com> wrote:
>> Hello out there,
>> currently Tk accepts only _gobal_ variables for widgets which set a
>> value. I always wondered why it doesn't also accept a fully namespaced
>> variable, too.
>
> Unless something has changed in 9, Tk has always accepted fully
> qualified namespaced variables for Tk widget variables.
>
> I.e.:
>
> $ rlwrap wish
> % namespace eval ns {
> variable someVar ""
> }
> % puts $::ns::someVar
>
> % ttk::radiobutton .r1 -text R1 -value R1 -variable ::ns::someVar
> .r1
> % ttk::radiobutton .r2 -text R2 -value R2 -variable ::ns::someVar
> .r2
> % pack .r1 .r2 -side top
> % puts $::ns::someVar
>
> % # clicks upon r1
> % puts $::ns::someVar
> R1
> % # clicks upon r2
> % puts $::ns::someVar
> R2
> %
>
> The thing is, they do have to be 'fully qualified' (which is something
> that is easy to forget).
>
>> In Tcl 8 a syntax like
>> -var ::ns::someVar
>> is not illegal: it just doesn't have any effect
>
> As I show above, it does. But, for a radio button, you do need to give
> each widget a -value or the widget never sets anything into the
> variable.
>

I think, the idea by Helmut is a bit different.
The idea is, that the command does a lookup in the caller namespace and
resolves the namespace within this scope.

E.g. the request is to have the following "namespace which"
automatically included into the command:
namespace eval ns {
variable someVar ""
ttk::radiobutton .r1 -text R1 -value R1 -variable [namespace which
-variable someVar]
}

This is a sensible request.
Unfortunately, currently, it does not work like that.
Currently, it is possible to revert the order, of widget and varible
creation:

ttk::radiobutton .r1 -text R1 -value R1 -variable someVar]
variable someVar ""

Or it is even possible to use a non-existing variable.
For example, ttk::checkbutton is set to the alternate state, if the
variable does not exist.

Helmut, I can understand the request. It would be handy.
It specially gets handy for oo widgets.
Sorry, Helmut, without a big redesign, this would not work due to many
incompatibilites.
In the mean time, it is good practice to always use [namepscpace which
-variable someVar] in the function call.
If you like, you may do a function for your own, which does this (untested):

proc myradiobutton {path args} {
if {[dict exist $args -command]} {
dict set args -commmand [uplevel 1 [namepsace which -variable [dict
get $args -command]]]
}
tailcall ttk::radiobutton $path {*}$args
}

Thank you for all,
Harald

Subject: Re: A suggestion for Tcl 9
From: Helmut Giese
Newsgroups: comp.lang.tcl
Organization: ratiosoft
Date: Sat, 16 Nov 2024 12:39 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: A suggestion for Tcl 9
Date: Sat, 16 Nov 2024 13:39:00 +0100
Organization: ratiosoft
Lines: 11
Message-ID: <dd4hjjhdl4dfko47vm3n7ikc3s2ho4ukl7@4ax.com>
References: <ka5lij9qa7jem9e2ina4ndndhot2ju40qh@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Nov 2024 13:39:00 +0100 (CET)
Injection-Info: dont-email.me; posting-host="275559a45f39d4111b20fe10c98b16f1";
logging-data="34927"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9cMNZ6qIiJbD2hK4y6jyC"
Cancel-Lock: sha1:TcXtWH9jz3qWLoQnhU6oB0GdUvg=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

Hello,
many thanks to both of you for responding. I am sorry to not having
reacted sooner but I was pretty sick (thank you Covid :( ).
@Rich: Your demo was quite convincing. Still, I'm sure that whenever I
tried it in the past it always failed - too late to find out why and
not really important.
@ Harald: Too much honor - my question was what Rich assumed. To tell
the truth: It took me quite a while to even understand what you
assumed I had meant - I am much simpler minded :)
Have a nice weekend
Helmut

Subject: Re: A suggestion for Tcl 9
From: Harald Oehlmann
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 16 Nov 2024 13:08 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: A suggestion for Tcl 9
Date: Sat, 16 Nov 2024 14:08:21 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <vha5g4$rcr$1@dont-email.me>
References: <ka5lij9qa7jem9e2ina4ndndhot2ju40qh@4ax.com>
<dd4hjjhdl4dfko47vm3n7ikc3s2ho4ukl7@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Nov 2024 14:08:20 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7ab1e5ceccc8e08fd006cae3b7b9fe22";
logging-data="28059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VZnwOh0y3WW8T8Fuoe1mv"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NJi+fm1HNLiNgA6/P2QCT/t4MV8=
Content-Language: en-GB
In-Reply-To: <dd4hjjhdl4dfko47vm3n7ikc3s2ho4ukl7@4ax.com>
View all headers

Am 16.11.2024 um 13:39 schrieb Helmut Giese:
> Hello,
> many thanks to both of you for responding. I am sorry to not having
> reacted sooner but I was pretty sick (thank you Covid :( ).
> @Rich: Your demo was quite convincing. Still, I'm sure that whenever I
> tried it in the past it always failed - too late to find out why and
> not really important.
> @ Harald: Too much honor - my question was what Rich assumed. To tell
> the truth: It took me quite a while to even understand what you
> assumed I had meant - I am much simpler minded :)
> Have a nice weekend
> Helmut

Good health to you !
What Rich proposes works.

Yes, no problem.
If you want it "simple", you may use the proposed way:

-variable [namespace which -variable someVar]

which cares to add the namespace resolution.

Take care,
Harald

1

rocksolid light 0.9.8
clearnet tor