Re: list or not a list?
- From: "MartinLemburg@UGS" <martin.lemburg.ugs@xxxxxxx>
- Date: 15 Jan 2007 09:54:11 -0800
Hello Bryan,
Does one or the other of those behaviors surprise you? Which one?
To be honest - none of those behaviours surprise me.
But ... to be honest too ... I was suprised, because I forgot the
grouping character of quotes inside a string, that is used as a list.
So - everything as simple as it should be with tcl!
Best regards,
Martin Lemburg
On Jan 15, 6:26 pm, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
MartinLemburg@UGS wrote:
Hello,
I was a bit astonished using such tcl code:
...
I thought, that the blank-separated characters in the string, treated
as list, will be recognized as list elements, but I can't really
understand, why the quotes surrounded by blanks are not recognized.
Can somebody light me up?When you implicitly cause a string to be converted to a list, such aswhen you do [llength $string], it is *not* the same as doing [split
$string]. As your code demonstrates, you get two different values.
As you can see, split takes it's job quite seriously -- it looks for
spaces and splits on each space. That is why you end up with seven
elements; each group of characters (including quotes) that are
surrounded by spaces becomes a list element.
OTOH, when implicitly converting a string to a list, the tcl parser
assumes that quote characters are used to delimit elements in the list.
Does one or the other of those behaviors surprise you? Which one?
.
- References:
- list or not a list?
- From: MartinLemburg@UGS
- Re: list or not a list?
- From: Bryan Oakley
- list or not a list?
- Prev by Date: Re: upvar behaviour
- Next by Date: Re: Console a security issue on MS Windows?
- Previous by thread: Re: list or not a list?
- Next by thread: Re: list or not a list?
- Index(es):
Relevant Pages
|