0

When I want to implement a my own procedure I have one doubt. For example, the following is OK:

% proc + {a b} {expr $a+$b}
% + 3 4
7

But when we are using "" instead of {}:

% proc + "a b" "expr $a+$b"

it will give this error:

can't read "a": no such variable

At the same time when we use \ it gives an answer:

% proc + "a b" "expr \$a+\$b"

Here, \ not considered $ as a special char then it will take as $a and it look same as the second example. Can anybody tell me the difference between these three methods of defining a proc?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Sri Reddy
  • 1
  • 1
  • I'm a little foggy on what this has to do with digital certificates... – twalberg Jul 23 '13 at 18:16
  • See [this question](http://stackoverflow.com/q/2193641/7552), the [syntax rules of Tcl](http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm) and the [Tcl tutorial](http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html) – glenn jackman Jul 23 '13 at 18:46

1 Answers1

2

The fundamental difference between quotes and curly braces is that variables are expanded inside of quotes, but not in curly braces. In the final example, when you place a backslash in front of the dollar sign, it removes the special nature of the dollar sign, thus the variable isn't initially expanded.

This is all explained on the Tcl man page. That single page is a remarkably concise and accurate description of the language.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685