while adding some shiny new pge tests for return context, i came
across this PIRism:

using keyed string access to the match object
##...
        rulesub = p6rule('$<A>:=(.)')
        match = rulesub('abc')
        .local string res
        res = match['A']
        print res
## prints: a

using keyed string access to the match object
##...
        rulesub = p6rule('$<A>:=(.)')
        match = rulesub('abc')
        .local string res
        res = match[0]
        print res
## errors: Null PMC access in get_string()

this is fixed by
##...
        rulesub = p6rule('$<A>:=(.)')
        match = rulesub('abc')
        .local string res
        $P0 = match[0]
        res = $P0
        print res
## prints: a

it seems that in keyed string access to the match object, the result
is returned directly as a string. in keyed integer access to the match
object, an intermediate pmc must be used. although the workaround is
simple, the lack of symmetry seems odd. is this due to PIR
restrictions, or to PGE implementation?

~jerry

Reply via email to