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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:33:39+00:00 2026-05-31T05:33:39+00:00

I saw some code in TCL like this: namespace eval ::info { set count

  • 0

I saw some code in TCL like this:

namespace eval ::info {
    set count 0;
    set id 1;
    set role admin;

    namespace export *
}



proc ::info::setcount {
    set ::info::count 0;
}

proc ::info::setId {
    set ::info::id 1;
}

proc ::info::setRole {
    set ::info::role user;
}

There are three variables defined in namespace ::info, but that three procs(setcount setId setRole) are not declared in the namespace, seems like they are defined outside of ::info, is this allowed? how does this work?

  • 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-31T05:33:40+00:00Added an answer on May 31, 2026 at 5:33 am

    The procedures are defined in the ::info namespace. They’re just not inside the scope of the namespace eval, a command that just creates the namespace if necessary and then executes the given script within that context. Being executed within the context of a namespace changes how proc places commands that it creates when the names of those commands are not fully-qualified. The namespace exists independently of the namespace eval call.
    The variables have to be declared in the namespace though; that avoids some really nasty trouble with resolution of variables that can catch people out.

    Personally, I prefer to write code like this:

    namespace eval ::foo {
        proc bar ... {
            ...
        }
    }
    

    But I know that other people disagree with me. Write what you prefer, as Tcl works just fine with either scheme.

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

Sidebar

Related Questions

I saw some code like this: try { db.store(mydata); } finally { db.cleanup(); }
I saw some code written by another developer that looks something like this: var
Just now,I saw some code like this: if(condition){ var xx='sss'; } //do something if(condition){
I saw some code, html form code which looks like this: <form name=form1 method=post
I saw some code on the apple website that goes like this id <NSFetchedResultsSectionInfo>
I saw some code like this: while(ajaxCallInProgress) { } ajaxCallInProgress = true; What is
Recently I saw some code like this: <tr> <th> Some label: </th> <td> <input
I saw some code like this: Why use MultiByteToWideChar and WideCharToMultiByte at the same
I saw this in some code: $(<p/>).append(<div>something</div>).appendTo(body); and noticed that it automatically closed the
I recently saw some code that reminded me to ask this question. Lately, I've

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.