Re: Proper way to split a string?

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Proper way to split a string?
De : emiliano (at) *nospam* example.invalid (Emiliano)
Groupes : comp.lang.tcl
Date : 21. Dec 2024, 04:41:42
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241221004142.8270d72a745f2a7513489c48@example.invalid>
References : 1
User-Agent : Sylpheed 3.5.1 (GTK+ 2.24.32; i686-pc-linux-gnu)
On Tue, 17 Dec 2024 01:37:49 -0300
Luc <luc@sep.invalid> wrote:

[snip]
OK, how about this:
 
bind $::SRw  <Return>  {set ::PINPUT "$pname::::::::::::::::$pfile"}

Incidentally, this wont work.

% set pname foo
foo
% set pfile bar
bar
% set ::PINPUT "$pname::::::::::::::::$pfile"
can't read "pname::::::::::::::::": no such variable

This is because there are two variable expansions in this expression:
one is ${pname::::::::::::::::} which is a variable in the (relative to
current scope) pname namespace with the with the empty string {} as
name (equivalent to [namespace eval pname {set {}}]) and the other is
$pfile. As the [namespace] documentation states, two or more colons are
namespace separators, so any number of colons > 2 are equivalent to "::".

Quoting the manual page:
"Extra colons in any separator part of a qualified name are ignored;
i.e. two or more colons are treated as a namespace separator.
A trailing :: in a qualified variable or command name refers to the
variable or command named {}."

Regards

--
Emiliano

Date Sujet#  Auteur
17 Dec 24 * Proper way to split a string?5Luc
17 Dec 24 +- Re: Proper way to split a string?1Rich
21 Dec 24 +- Re: Proper way to split a string?1Emiliano
21 Dec 24 `* Re: Proper way to split a string?2Luc
21 Dec 24  `- Re: Proper way to split a string?1Rich

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal