Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:39:29+00:00 2026-05-20T09:39:29+00:00

I have used some TCL, but this construction stumps me. When $res = Table

  • 0

I have used some TCL, but this construction stumps me.

When $res = “Table does not exist”, what will the following return?

[list [list {*}$res]]

I know what [list [list $res]] would do, but the extra {*} just baffles me.

Thanks for helping.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:39:29+00:00Added an answer on May 20, 2026 at 9:39 am

    When $res = "Table does not exist", what will the following return?

    [list [list {*}$res]]
    

    Well, first know that [list {*}…] is a construct that returns a list of the words in the ellipsis (the contents of the res variable in your case). It happens that in your case, the net effect is nothing as the input string is actually also a well-formed list. That then becomes a single argument to the outer list and so we get a single-element list as result, whose element contains a list of the words Table, does, not and exist in that order, i.e., {Table does not exist}.

    Notes on expansion

    The list of expanded word form is useful for doing concatenation of lists; the concat command does something similar (but not identical; there are some historical weirdnesses involved in the concat command). Thus, you’d concatenate two lists like this:

    set concatenation [list {*}$list1 {*}$list2]
    

    Also note that expansion (introduced in Tcl 8.5) is true syntax, which is a very unusual thing in Tcl. The {*} changes the nature of the following substitution so that it yields multiple words instead of just one. While it is possible to do without it, it’s actually remarkably difficult to get right. For example, without it the above would be:

    set concatenation [eval [linsert $list1 0 list] [lrange $list2 0 end]]
    

    The introduction of expansion has greatly reduced the number of calls to eval required in most Tcl code (a benefit since it was hard to write properly; a lot of programmers were caught out by the difficulty). This has proved particularly beneficial in practice with the exec command; it makes working with glob and auto_execok much easier:

    exec {*}[auto_execok $someCmd] $arg1 {*}[glob *.foo]
    # Instead of:
    #eval [linsert [auto_execok $someCmd] 0 exec] [linsert [glob *.foo] 0 $arg1]
    # Or this _wrong_ version:
    #eval exec [auto_execok $someCmd] $arg1 [glob *.foo]
    

    Ugh. That last one was a bit brain-bending to write out in non-expansion form even though I know what I’m doing. (The wrong version is wrong because it falls apart if $arg1 contains Tcl meta-characters…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used Anchor property for some of my controls at design time. but
For some reason, YQL's XSLT table can't parse my stylesheet. I have used the
During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
I've worked with MySQL and MSSQL for some time and have used a variety
I have a .rc file which is used to include some text data in
We used to have a search, that checks two columns for some words. Both
I have some WCF methods that are used to transmit information from a server
I've never used the Global Temporary Tables however I have some questions how they
I have a question with fluent interfaces. We have some objects that are used
I am used to writing C# Windows applications. However, I have some free hosted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.