From: chromatic <[EMAIL PROTECTED]>
   Date: Sun, 24 Dec 2006 10:56:42 -0800

   I'm writing tests for namespaces now (and fixing code), and testing the 
keyed 
   variants is a real pain, mostly because creating nested Key PMCs in PIR is 
so 
   face-stabbingly awful, if it's even possible.

It's possible, all right, but there do seem to be lots of pitfalls.
Ever try to print an uninitialized key?  It results in an unbounded
recursion on VTABLE_get_string . . .

   Without hard-coding the names, I'd love to see working PIR for creating a 
key 
   which can refer to the namespace [ 'A'; 'Nested'; 'Namespace' ].

   Yes, that implies an interface like:

           .local pmc some_key
           some_key = create_nested_key( 'A', 'Nested', 'Namespace' )

   Anyone?

   -- c

Is this what you had in mind?

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

## Given one or more names, create a Key that contains them first to last.
.sub create_nested_key
        .param string name
        .param pmc other_names :slurpy

        .local pmc key
        key = new .Key
        key = name
        $I0 = other_names
        if $I0 goto nested
        .return (key)
nested:
        .local pmc tail
        tail = create_nested_key(other_names :flat)
        push key, tail
        .return (key)
ret:
.end

.sub test :main
        .local pmc some_key
        some_key = create_nested_key( 'A', 'Nested', 'Namespace' )
        ## some_key = new .Key

        $S0 = typeof some_key
        print $S0
        print ':  '
        print some_key
        $P1 = shift some_key
next:
        if null $P1 goto end
        print ' => '
        print $P1
        $P1 = shift $P1
        goto next
end:
        print "\n"
.end

Reply via email to