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 8257289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:08:58+00:00 2026-06-08T02:08:58+00:00

I am having some problems understanding the use of uplevel in TCL. I am

  • 0

I am having some problems understanding the use of uplevel in TCL. I am reading Brent Welch’s Practical programming in TCL and Tk and there is an example in uplevel that I cannot understand. Here it is:

proc lassign {valueList args} {
  if {[llength $args] == 0} {
    error "wrong # args:lassign list varname ?varname...?"
  }
  if {[llength $valueList] == 0} {
    #Ensure one trip through the foreach loop
    set valueList [List {}]
  }
  uplevel 1 [list foreach $args $valueList {break}]
  return [lrange $valueList [llength $args] end]
}

Can someone please explain it to me? The explanation in the book does not help me enough 🙁

  • 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-06-08T02:09:02+00:00Added an answer on June 8, 2026 at 2:09 am

    The uplevel command executes a command (or in fact a script) in another scope than that of the current procedure. In particular, in this case it is uplevel 1 which means “execute in caller”. (You can also execute in the global scope with uplevel #0, or in other places too such as the caller’s caller with uplevel 2 but that’s really rare.)

    Explaining the rest of that line: the use of the list here is as a way of constructing a substitution-free command, which consists of four words, foreach, the contents of the args variable, the contents of valueList variable, and break (which didn’t actually need to be in braces). That will assign a value from the front of valueList to each variable listed in args, and then stop, and it will do so in the context of the caller.

    Overall, the procedure works just like the built-in lassign in 8.5 (assuming a non-empty input list and variable list), except slower because of the complexity of swapping between scopes and things like that.

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

Sidebar

Related Questions

I’m learning to use the MVC 3 Framework, but I'm having some problems understanding
I'm having some problems understanding mock objects. What I want is an observer that
I am having some problems with the PDF files that I make using the
I'm having some problems with some commands in Java. I created a JAR that
I'm having some problems using / understanding is_dir. (Yes, I have read the PHP
I'm having some problems with understanding the activity stack and the behaviour of how
I am having some trouble understanding how to use Unix's fork() . I am
I'm having some problems understanding what I'm doing wrong. What I do: Override getHomePage()
I've been having some difficulty in understanding the source of a problem. Below is
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')

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.