In other dynamic typed, interpeted languages (Ruby, PERL...), one can defined a key in a hash as an inline of a function call. For example (in Ruby:
a[ foo(1) ] = bar
I have tried to do the same in Tcl 8.4, but failed, see tclsh log below:
% proc add1 { x } { expr {$x + 1 } }
% array set p {}
% set p( [add1 1]) 0
wrong # args: should be "set varName ?newValue?"
Needsless to say, that I assign a variable to the output of of add1 1, and use the variable value, it does work:
% set a [add1 1]
2
% set p($a) 0
0
It is a style issue, no doubt, but I like inlining functions, and not using intermediate vriables. Any suggestions?