Re: list or not a list?



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 as
when 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?

.



Relevant Pages

  • Re: Open, Close, & Freefile
    ... statement adds characters such as quotes around string data. ... Write #fnum, "This is some text..." ... VB writes out the quotes whether a literal or in a variable. ... It is imo on the same line as using the trailing "$" on string intrinsics to ensure the character version is returned as opposed to Variant when that is what is intended, etc., ... ...
    (microsoft.public.vb.general.discussion)
  • Mandis Quotes (aka retiring """ and )
    ... arbitrary textual matter called "Mandis quotes". ... surround the string by a pair of doubled single quotes. ... of ASCII or Unicode characters, but instead as a sequence of lines ...
    (comp.lang.python)
  • Re: Commodore 128 Basic 7.0 One Liner Competition 2008
    ... the characters in the string and put them into memory. ... You could put a REM statement at the end of the line with a bunch ... of characters in quotes and have a SYS command at the beginning of the ...
    (comp.sys.cbm)
  • Re: list or not a list?
    ... 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 ... That is why you end up with seven elements; each group of characters that are surrounded by spaces becomes a list element. ...
    (comp.lang.tcl)
  • RE: Replacing "illegal characters" in html
    ... > in a string. ... > The characters I need to replace come from MS Word copy & ... > Double Right quotes ... and 2) regular expressions. ...
    (comp.lang.python)