On Tue, Sep 8, 2009 at 8:01 PM, Theodore Reed<[email protected]> wrote:
> On Mon, Sep 7, 2009 at 19:08, Jonathan Leto<[email protected]> wrote:
>> Howdy,
>>
>> Should one be able to push up to a fixed number of elements onto a
>> FixedPMCArray?
>
> Now, I realize that I may be newish here, so forgive me if I'm talking
> completely out of my ass, but to me the idea of pushing/popping or
> shifting/unshifting a Fixed anything seems like it's just
> inappropriate; the very notion of these operations implies a change in
> the size of the Array.
>
> Is there a good reason to not just use keyed set?
>
>> For example, should the following code put a number in the first slot of $P0?
>>
>> new $P0, 'FixedPMCArray'
>> $P0 = 5
>> push $P0, 42
>
> I'm guessing that from your text above, you intend the implementation
> to permit exactly five pushes before... what? An exception is thrown?
> You'd need to track how far things have been pushed, and maybe even
> the "has_been_set" status of every element.
>
> What happens in the following situation?
>
> new $P0, 'FixedPMCArray'
> $P0 = 5
> $P0[2] = 1
> push $P0, 2
> push $P0, 3
> push $P0, 4
>
> And are you going to do all of push/pop/shift/unshift? Then you'd need
> to track from both sides, in interesting ways. (How would successive
> pops even be handled if you're not removing things?)
>
> I'm just not convinced that these operations make any sort of sense in
> the context of a Fixed-size Array.
>
> -- treed
> _______________________________________________
> http://lists.parrot.org/mailman/listinfo/parrot-dev
>

>From my point of view, I expect that if I am handed an PMC that claims
to "does 'array'", that I should be able to invoke all the
array-related opcodes/vtables. If I'm working with my own PMCs, I'll
chose the right one for the job; if I'm a library, I should work on as
many types as possible.

If the fixed arrays are going to be differently-abled than the
variable pmcs, they should at least claim to support a different
interface. This will become more of an issue if 'does <foo>' is ever
normative instead of informative.

If it's more /expensive/ to call push vs. direct set, that's fine,
IMO. We can advertise the more efficient way, but allow a reasonable
fallback.

[0] Yes, in the edge case, this will throw an exception. but in my
case it throws an exception in the exceptional case, and works most of
the time, instead of throwing an exception all the time; in EITHER
case, careful users will have to use exception handlers on any opcode
that calls a vtable (since they can all throw an exception).

-- 
Will "Coke" Coleda
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to