Re: Syntax, expressiveness and the beauty of Tcl



Stephan Kuhagen wrote:
slebetman@xxxxxxxxx wrote:
I will have a closer look into that, looks cool to me. Does your example
imply that the variable must exist before it can be used that way? This
would be very C-like, more that I expected... ;-)

No. 'Normal' variables don't inherit that behavior (for that you can
use the [unknown] trick). Instead the [var] command is used to create
C-like variables:

var x = 10
var y

x = $x * 2
y = $x * $x
x = $y
y = 0

puts $x
puts $y

Notice that since x and y are proper procs, they can also be used like
this:

y = [x]
x = [x] + [y]

but I think $x looks nicer than [x]. Besides, for me, in my code, [x]
signifies a constant (I use procs to define global constants).

.



Relevant Pages

  • Re: Is the word "this" a key word in TCL?
    ... set::A,var Gumbo ... puts $ ... Tcl uses special parsing rules to evaluate the ... set {A var} Gumbo ...
    (comp.lang.tcl)
  • Re: Is the word "this" a key word in TCL?
    ... set::A,var Gumbo ... The correct code would be: ... puts $ ... set {A var} Gumbo ...
    (comp.lang.tcl)
  • Re: eval bind
    ... puts eval.class.instance_methods.sort ... undefined local variable or method `var' for main:Object (NameError) ... so the returned value is nil. ...
    (comp.lang.ruby)
  • Re: block as string
    ... while I think RubyMacro is a great idea, ... $var = "global var" ... puts "Line 1" ... RubyMacros is an implementation of lisp-like macros for ruby.... ...
    (comp.lang.ruby)
  • Re: Single backslash in a string. How??
    ... I want var to have the value "\foo" ... irb:003:0> puts var.length ... backslash character you entered as an actual character vs. treating it as an ...
    (comp.lang.ruby)