From: Tom Tromey <tromey@adacore.com>
To: Simon Marchi <simark@simark.ca>
Cc: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix Tcl quoting in gdb_assert
Date: Thu, 16 Feb 2023 11:12:43 -0700 [thread overview]
Message-ID: <87h6vlpjhg.fsf@tromey.com> (raw)
In-Reply-To: <bc1a81ef-cb63-eeac-8147-15561254a183@simark.ca> (Simon Marchi's message of "Thu, 16 Feb 2023 11:06:32 -0500")
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>> - set code [catch {uplevel 1 expr $condition} res]
>> + set code [catch {uplevel 1 [list expr $condition]} res]
Simon> I don't understand why this would be needed. The doc of uplevel says:
Simon> All of the arg arguments are concatenated as if they had been passed
Simon> to concat
"concat" is simple string concatenation, but "list" also supplies list
quoting.
Here's a simple example:
% set text "hello Simon"
hello Simon
% uplevel 0 puts $text
can not find channel named "hello"
% uplevel 0 [list puts $text]
hello Simon
Or more directly:
% concat puts $text
puts hello Simon
% list puts $text
puts {hello Simon}
Here you can see the result of the [concat] isn't a valid command.
Simon> So, I'm not saying your fix is wrong, I am just saying I don't
Simon> understand the situation.
This part of Tcl has always confused people, you're not alone. But
basically, for eval-like things you normally want to quote with [list].
I'm not totally sure why it works the way it does, but it might be
because Tcl didn't have a "splat" operator in the early days, so
un-quoting a list to write something like "apply" was more of a pain.
Tom
next prev parent reply other threads:[~2023-02-16 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 21:58 Tom Tromey
2023-02-16 16:06 ` Simon Marchi
2023-02-16 18:12 ` Tom Tromey [this message]
2023-02-23 18:11 ` Tom Tromey
2023-02-23 19:16 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6vlpjhg.fsf@tromey.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).