Iter -- A PIR-based Iterator Object


An iterator with an object-oriented interface, written in PIR. Currently implemented only for Array type PMCs. Expect Hash support shortly.


    load_bytecode 'Iter.pir'
    .local pmc iter
               iter = new 'Iter'

    ## initialize the iterator

    ## advance to the next item in the iterator

    ## check for exhaustion
    $I0 = iter.'exhausted'()
    if $I0 goto done

    ## get the value from the iterator
    $P0 = iter.'value'()

    ## alternate interface to advance and get the value
    $P0 = iter.'nextval'()

Iter Methods ^

.'start'(PMC aggregate)

Initialize the iterator. Must pass a PMC aggregate, or an exception is thrown.


Sets the internal value attribute to the value of the next item from the iterator. Sets the internal exhausted attribute if the iterator is exhausted.


Returns true (1) if the iterator is exhausted. Returns false (0) otherwise.


Returns the current value from the iterator. Returns PMCNULL if exhausted.


Executes .'next'(), and returns .'value'().


Jerry Gay a.k.a. particle