On Sat, Mar 8, 2008 at 2:59 PM, chromatic <[EMAIL PROTECTED]> wrote: > On Thursday 06 March 2008 06:22:21 Will Coleda wrote: > > > > in PDD17, the following program (which prints "b\n" in trunk), dies: > > > > $ ../../parrot tcl.pbc -e "puts [concat {expand}[lindex {a b} 1]]" > > argument doesn't array. > > Ha. The problem's not Parrot (as far as I can tell) but Tcl. {a b} is a > two-element list, right?
No. {a b} is a string with no interpolation done. > > Take t/cmd_expr.t, which sets a variable named TODO: > > set TODO {TODO "correct precision"} > > # math functions, happy path > is [expr abs(-1)] 1 > is [expr abs(1)] 1 > is [expr abs(1.0)] 1.0 > is [expr abs(-1.0)] 1.0 > is [expr acos(0)] 1.5707963267948966 {} $TODO > is [expr asin(1)] 1.5707963267948966 {} $TODO > > The acos() and asin() tests cause an abort in Parrot, with the "argument > doesn't array" message. This makes sense; is() expects that the fourth > argument is a two-element list: > > proc is {value expected {description ""} {special {}}} { This syntax means that is takes four arguments. the last two, description and special, both have default values, which are both the empty string, but are confusingly specified as "" and {}. (like using '' and "" in perl} When we say [llength $special] in the body of is, this takes the PMC argument (variable named special), and calls the builtin converter '__list' on it. List converts the PMC in place to a list if possible, and with the string {a b}, that converts to a two element list, as expected: but this isn't done at compile time. > However, if you dump this code to PIR, you'll see: > > $P102 = new 'TclString' > assign $P102, "TODO" > $P103 = new 'TclString' > assign $P103, "TODO \"correct precision\"" > if epoch != 0 goto dynamic_109 > .local pmc a_varName_108 > a_varName_108 = $P102 > .local pmc a_newValue_108 > a_newValue_108 = $P103 > .local pmc temp > > if null a_newValue_108 goto read_var_108 > > .local pmc set_108 > set_108 = get_root_global ['_tcl'], '__set' > $P104 = set_108(a_varName_108, a_newValue_108) > > ... which indicates to me that TODO gets stored as a string, not a list. Yes, exactly right. > -- c -- Will "Coke" Coleda