From: Lars H. <Lar...@re...> - 2011-08-06 13:11:44
|
Sorry to bother in the middle of the 8.6b2rc testing, but it seems to be longer than first expected. Also, I've been reminded that the GSoC "soft pencils down" milestone approaches, and this is a matter that should be resolved before that. I've got two API changes for my stasher package that I'd like to receive comments on. In short, the issues are: 1. What should I name the generalisation of the "apply" subcommand? 2. Parametrised properties: A separate kind of stasher, something the basic stasher should support, or a feature that's not needed? Below is an explanation of issue 1. Issue 2 needs elaborating too (probably more than issue 1), but I'll post that in a separate mail later tonight. 1. Replacement for "apply" subcommand. The v0.3 "apply" subcommand of a stasher uses a computed property as lambda in a call to [apply]. Practically, a command prefix $S apply (where $S is a stasher) is equivalent to the command *prefix* apply {{S properties value args} { set data {} foreach p $properties { lappend data [$S get $value $p] } tailcall apply {*}$data {*}$args } ::} $S (A usage example can be something like polynomial apply hornerlambda {1 - x + 1/2 x^2 - 1/6 x^3 + 1/24 x^4} 0.3 which ends up making the call ::apply {x {expr {(((((0)*$x+0.041666666666666664)*$x+-0.16666666666666666)*$x+0.5)*$x+-1)*$x+1}} ::} 0.3 given the [polynomial] stasher defined in examples/polynomial.tcl file of the v0.3.1 stasher distro. Yes, that initial (0)*$x+ is redundant.) Anyway, it then occurred to me that this is really a special case of a slightly more general operation, where instead of ::apply the command uses an arbitrary command prefix. Tentatively calling the new subcommand "to", one would find that the old $STASHER apply becomes equivalent to $STASHER to ::apply and more generally that the command prefix "$STASHER to" is equivalent to apply {{S prefix properties value args} { set data {} foreach p $properties { lappend data [$S get $value $p] } tailcall {*}$prefix {*}$data {*}$args } ::} $STASHER However, I'm not sure "to" is the most obvious name for this subcommand. Maybe "call" would be better? (Both appear as stems in core command names: [yieldto] and [tailcall].) Or something else? ("eval" is not available, on account of being a separate subcommand.) Lars Hellström |