Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You never hesitate to tackle the most difficult problems.


comp / comp.lang.tcl / Re: add additional subcommand for the "chan" tcl command?

SubjectAuthor
* add additional subcommand for the "chan" tcl command?aotto1968
`* Re: add additional subcommand for the "chan" tcl command?Schelte
 +- Re: add additional subcommand for the "chan" tcl command?aotto1968
 `* Re: add additional subcommand for the "chan" tcl command?aotto1968
  `- Re: add additional subcommand for the "chan" tcl command?aotto1968

1
Subject: add additional subcommand for the "chan" tcl command?
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 13:20 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: add additional subcommand for the "chan" tcl command?
Date: Mon, 17 Jun 2024 15:20:35 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <v4pd73$m2ov$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Jun 2024 15:20:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="99029a410294a3ada18bf84db41ce36a";
logging-data="723743"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JSZf0aq8NyKJxSE3dQ62dXM/w5Tnzv+I="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nWLXyC9YW+KMp7jLFND2A8iVaj0=
Content-Language: en-US
View all headers

Hi,

I would like to add "chan exists str" just to signal a boolean return on exists and I want to do this
*without* to touch the tcl distribution.

there is already a feature like "::tcl:mathfunc::????" to add an additional function to "expr" and I
ask me now it is possible to do such a kind of "addition" to the "chan" command as well ?

mfg ao

Subject: Re: add additional subcommand for the "chan" tcl command?
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Mon, 17 Jun 2024 14:11 UTC
References: 1
Date: Mon, 17 Jun 2024 16:11:14 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: add additional subcommand for the "chan" tcl command?
Newsgroups: comp.lang.tcl
References: <v4pd73$m2ov$1@dont-email.me>
Content-Language: en-US
From: nospam@wanadoo.nl (Schelte)
In-Reply-To: <v4pd73$m2ov$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb>
Organization: KPN B.V.
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 33
Injection-Date: Mon, 17 Jun 2024 16:11:16 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
View all headers

On 17/06/2024 15:20, aotto1968 wrote:
>  I would like to add "chan exists str" just to signal a boolean return
> on exists and I want to do this
>  *without* to touch the tcl distribution.
>
>  there is already a feature like "::tcl:mathfunc::????" to add an
> additional function to "expr" and I
>  ask me now it is possible to do such a kind of "addition" to the
> "chan" command as well ?
>
The chan command is an ensemble, so you can add your own subcommands. It
is a bit more work than adding a math function, but not too much:

proc chanexists {fd} {
return [expr {$fd in [chan names]}]
} namespace ensemble configure chan -map [dict replace \
[namespace ensemble configure chan -map] exists ::chanexists]

After that, you get the following results:
% chan help
unknown or ambiguous subcommand "help": must be blocked, close,
configure, copy, create, eof, event, exists, flush, gets, names,
pending, pipe, pop, postevent, push, puts, read, seek, tell, or truncate
% chan exists stdin
1 % chan exists nosuchchan
0

Schelte.

Subject: Re: add additional subcommand for the "chan" tcl command?
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 19:21 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: add additional subcommand for the "chan" tcl command?
Date: Mon, 17 Jun 2024 21:21:18 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <v4q2be$sq8k$1@dont-email.me>
References: <v4pd73$m2ov$1@dont-email.me>
<nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 21:21:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="99029a410294a3ada18bf84db41ce36a";
logging-data="944404"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TpN/EMVP8elVv0bau/ACZ9TRpoViYRXk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kBDtzdNhrwVPJLBVLtGF0v7EIk8=
In-Reply-To: <nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb>
Content-Language: en-US
View all headers

thanks … the technology to add my own ensemble-command into an existing ensemble should be more used.

On 17.06.24 16:11, Schelte wrote:
> On 17/06/2024 15:20, aotto1968 wrote:
>>   I would like to add "chan exists str" just to signal a boolean return on exists and I want to do this
>>   *without* to touch the tcl distribution.
>>
>>   there is already a feature like "::tcl:mathfunc::????" to add an additional function to "expr" and I
>>   ask me now it is possible to do such a kind of "addition" to the "chan" command as well ?
>>
> The chan command is an ensemble, so you can add your own subcommands. It is a bit more work than adding a math function, but not
> too much:
>
> proc chanexists {fd} {
>     return [expr {$fd in [chan names]}]
> }
> namespace ensemble configure chan -map [dict replace \
>   [namespace ensemble configure chan -map] exists ::chanexists]
>
> After that, you get the following results:
> % chan help
> unknown or ambiguous subcommand "help": must be blocked, close, configure, copy, create, eof, event, exists, flush, gets, names,
> pending, pipe, pop, postevent, push, puts, read, seek, tell, or truncate
> % chan exists stdin
> 1
> % chan exists nosuchchan
> 0
>
>
> Schelte.
>

Subject: Re: add additional subcommand for the "chan" tcl command?
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 19:39 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: add additional subcommand for the "chan" tcl command?
Date: Mon, 17 Jun 2024 21:39:31 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <v4q3dj$sq8k$2@dont-email.me>
References: <v4pd73$m2ov$1@dont-email.me>
<nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 21:39:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="99029a410294a3ada18bf84db41ce36a";
logging-data="944404"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+stYgSJC9Iwe3J+LN9bCUdvSTLRQlejH0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cH8K0nNfKcLyBX7GRYrca95QNP8=
Content-Language: en-US
In-Reply-To: <nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb>
View all headers

On 17.06.24 16:11, Schelte wrote:
> chan exists stdin

question: is this possible with an additional level?

proc chanexists {fd} {
return [expr {$fd in [chan names]}]
} namespace ensemble configure chan -map [dict replace \
[namespace ensemble configure chan -map] exists ::chanexists]

#chan help

puts [chan exists stdin] ; # → OK

# problem: "ensemble" is an ensemble IN the "namespace" ensemble
# goal: namespace ensemble add ENSEMBLE NAME CMD

proc ::namespace_ensemble_add {ensb name cmd} {
namespace ensemble configure $ensb -map [dict replace \
[namespace ensemble configure $ensb -map] $name $cmd]
}

→ how I do this for a *two* level ensemble (ensemble in a ensemble) ?

Subject: Re: add additional subcommand for the "chan" tcl command?
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 06:10 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: add additional subcommand for the "chan" tcl command?
Date: Tue, 18 Jun 2024 08:10:47 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <v4r8d7$1779p$1@dont-email.me>
References: <v4pd73$m2ov$1@dont-email.me>
<nnd$5800c649$6c7c9ec6@3c4b42606e7ba6bb> <v4q3dj$sq8k$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 18 Jun 2024 08:10:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="acff8b0cb802310bf0109628909101c1";
logging-data="1285433"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nbUz+VC9DWtXjmHKZmWbqKg3a15kRoSA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8D5N3RktRAgNL+LBanU30dQntXg=
In-Reply-To: <v4q3dj$sq8k$2@dont-email.me>
Content-Language: en-US
View all headers

ok… "namespace ensemble" is not an ensemble"
namespace ensemble configure namespace -map =
children = ::tcl::namespace::children
code = ::tcl::namespace::code
current = ::tcl::namespace::current
delete = ::tcl::namespace::delete
ensemble = ::tcl::namespace::ensemble
eval = ::tcl::namespace::eval
exists = ::tcl::namespace::exists
export = ::tcl::namespace::export
forget = ::tcl::namespace::forget
import = ::tcl::namespace::import
inscope = ::tcl::namespace::inscope
origin = ::tcl::namespace::origin
parent = ::tcl::namespace::parent
path = ::tcl::namespace::path
qualifiers = ::tcl::namespace::qualifiers
tail = ::tcl::namespace::tail
unknown = ::tcl::namespace::unknown
upvar = ::tcl::namespace::upvar
which = ::tcl::namespace::which
namespace ensemble configure ::tcl::namespace::ensemble -map = "::tcl::namespace::ensemble" is not an ensemble command
info body ::tcl::namespace::ensemble = "::tcl::namespace::ensemble" isn't a procedure

1

rocksolid light 0.9.8
clearnet tor