On Wed, 27 Aug 2003, Matt Fowles wrote:
> Dan~
>
> I still don't see why this necessitates keyed variants of all the ops.
> Couldn't we have a "prepkeyed" op which would return a specialized pmc
> to use in the next op?
We could--perl 5 uses a variant of this where active aggregates return a
placeholder variable with magic on it that then does the appropriate thing
when operated on. I can, though, learn from other people's mistakes if
they hurt enough. :)
Besides requiring active aggregates to create magic PMCs, it makes
accessing compact aggregates very inefficient. Consider the case where we
have an integer array we're working with--it means code like:
foreach loopvar (1..10000) {
total[loopvar] = somedata[loopvar] + otherdata[loopvar];
}
(That addition, BTW, could be a single op with keyed addition in the
vtables, though I wouldn't expect the majority of the usage to be that
simple)
If either (or both) of somedata or otherdata isn't an array of PMCs,
there's going to be an awful lot of temporary PMC creation, which is a
waste. We're trying to encourage the use of more compact aggregate
representations with Parrot, as currently Perl/Python/Ruby all have really
portly aggregates and part of the design goals is to allow for compact
versions in places we can be compact.
Dan