Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie question: why is $ inside {} only interpreted sometimes?

2 views
Skip to first unread message

Mark_Galeck

unread,
Aug 20, 2009, 4:22:13 PM8/20/09
to
Hello, why is this:

%set foo 1
1
%puts {$foo}
$foo
%if {1} {puts $foo}
1

in other words, why is $ inside {} sometimes interpreted and sometimes
literal?

Thank you,

Mark

Bruce

unread,
Aug 20, 2009, 4:40:56 PM8/20/09
to
the {} prevents the Tcl parser from interpreting it in *all* cases
some commands (like "if" above) will take an argument and possibly
re-evaluate the contents - that is what you are seeing.

Bruce

Mark_Galeck

unread,
Aug 20, 2009, 4:49:55 PM8/20/09
to
I see, the "if" manual entry says, it will pass the contents inside of
{} to the Tcl interpreter - clear! thank you very much! Mark

Georgios Petasis

unread,
Aug 20, 2009, 5:34:35 PM8/20/09
to Mark_Galeck
O/H Mark_Galeck έγραψε:

> I see, the "if" manual entry says, it will pass the contents inside of
> {} to the Tcl interpreter - clear! thank you very much! Mark
>

Yes. When there is a condition (if, for, while, etc.) some arguments are
passed to the expr command, which evaluates them...

George

0 new messages