Sujet : Re: confused about lists and strings...
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.lang.tclDate : 02. Jul 2025, 13:59:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <1043afk$3h3vi$2@dont-email.me>
References : 1 2 3
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Mark Summerfield <
m.n.summerfield@gmail.com> wrote:
Thanks, I hadn't realised that using `args` would give me a list in a
list.
The proc man page documents this 'special nature' of 'args' (note the
third sentence below):
There is one special case to permit procedures with variable numbers
of arguments. If the last formal argument has the name “args”, then
a call to the procedure may contain more actual arguments than the
proce‐ dure has formal arguments. In this case, all of the actual
arguments starting at the one that would be assigned to args are
combined into a list (as if the list command had been used); this
combined value is as‐ signed to the local variable args.
Note also from the above that it is only 'special' when it is the "last
argument" to the proc.
$ rlwrap tclsh
% proc abc {args y} {puts "args='$args' y='$y'" }
% abc 1 2
args='1' y='2'
%