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

  • Home
  • SEARCH
  • 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 6535873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:25:28+00:00 2026-05-25T10:25:28+00:00

I am just going to use Perl as a comparison here: $foo = 5;

  • 0

I am just going to use Perl as a comparison here:

$foo = 5;
print $foo;

sets the variable $foo to 5, and then prints the contents of the variable (notice that $foo is always accessed as $foo).

In Tcl:

set foo 5
puts $foo

does the same thing as the Perl counterpart.

Why doesn’t Tcl set variables with the “$”, but need a “$” to access a variable?
Why is this true for procedures too (e.g.proc bar {spam eggs} {...})?
To me, the Tcl code looks like this (in pseudocode):

"foo" = 5 # Setting a string?
puts $foo # "$foo" is not defined.

(my comments only reflect what appears to be happening, not what is happening).

Another point I want to add is the clarity of this:

set foo foo

Yeah, I could always do set foo "foo", but isn’t set $foo foo more consistent?

From what I know, “foo” can be a variable or a string, depending on the situation, as seen in my last example (set foo foo = set var string), but I don’t get this syntax (maybe because I’m used to Python…)

  • 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-25T10:25:29+00:00Added an answer on May 25, 2026 at 10:25 am

    I think the original Tcl only had the set command, so the only way to fetch the contents of a variable “foo” was calling set foo. But as Tcl progressed into the domain of general-purpose scripting languages (recall that Tcl was envisioned as being an embeddable language where you use a thin layer of Tcl over compilcated components written in C, so one wasn’t expected to use lots of variables), it was deemed that that $varname syntactic sugar is useful and so it was added.

    In other words, Tcl does not use “$” in the same way as Perl does, in which the “$” means “interpret whatever follows as a scalar”, neither does “$” in Tcl denote a variable. Instead it merely a syntactic sugar for “give me the value of a variable whose name is given by the immediately following word”.

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

Sidebar

Related Questions

Just looking for the first step basic solution here that keeps the honest people
I am just trying to learn some Perl, so I am going through one
I'm going through Intermediate Perl and it's pretty cool. I just finished the section
I just downloaded MVC and I am going through a tutorial. Everything goes fine
I am going to develop ICQ client and I just wonder where can I
I'm going to learn Qt and I just want to know what parts of
Just getting started using MVC in ASP.NET, I'm going to have it so users
This is likely going to be an easy answer and I'm just missing something,
There is a similar question going around, but it just got the same old
I am going to spend 30 minutes teaching Perl to an experienced programmer. The

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.