0xfaded / eval

BSD 3-Clause "New" or "Revised" License
34 stars 7 forks source link

Handle array/slice indexing #4

Closed rocky closed 10 years ago

rocky commented 10 years ago

If it were done, for example, one could access previous results in which demo/eval.go saves after evaluation in the Results[] slice.

0xfaded commented 10 years ago

This is not the case. If an expression evaluates to a single value, then that value is immediately available. What is really needed is a means of unpacking multiple values into single named values for future use.

rocky commented 10 years ago

I'm not understanding you. So let me be less abstract:

$ ./eval ./eval go> 1+2 1+2 Kind = int64 Results[0] = 3 go> Results Results Kind = slice Results[1] = [3] go> Results[0] Results[0] Kind = string Results[2] = "Alice" go>

See https://github.com/0xfaded/go-interactive/blob/master/expr.go#L36 where that clause is empty.

0xfaded commented 10 years ago

OK, I didn't realise that results was being put back into global scope. This will need to be done sooner or later anyway and it doesn't interfere with my typed evaluation branch. I'll add this today

Carl 2013/12/10 11:56 "R. Bernstein" notifications@github.com:

I'm not understanding you. So let me be less abstract:

$ ./eval ./eval go> 1+2 1+2 Kind = int64 Results[0] = 3 go> Results Results Kind = slice Results[1] = [3] go> Results[0] Results[0] Kind = string Results[2] = "Alice" go>

See https://github.com/0xfaded/go-interactive/blob/master/expr.go#L36where that clause is empty.

— Reply to this email directly or view it on GitHubhttps://github.com/0xfaded/go-interactive/issues/4#issuecomment-30190366 .