How to say "provides foo" in PIR?

Will Coleda will at coleda.com
Mon Jan 19 08:39:48 UTC 2009


On Mon, Jan 19, 2009 at 3:20 AM, chromatic <chromatic at wgz.org> wrote:
> On Monday 19 January 2009 00:11:11 Will Coleda wrote:
>
>> When constructing a PMC, I can say "provides something" in the pmclass
>> declaration. I just tried converting a PMC with this annotation to
>> PIR, and couldn't find a way to set this.
>>
>> Looks like that declaration modifies the provides_str member of the
>> PMC; searching for provides_str gives me (outside of the PMC code
>> generation), no way to set this.
>>
>> Any suggestions?
>
> Override the 'does' vtable entry.
>
> -- c
>

Ah, thank you.

My first joking response was going to be: "That's far too simple,
it'll never work. ;)"; I apparently jinxed myself.

I tested it and it doesn't seem to work; the override isn't invoked;
This prints out '0' and nothing else. (using does_pmc instead has the
same non-effect).


.sub foo :main
 $P1 = new 'TclArray'
 $I0 = does $P1, 'foo'
 say $I0
.end

.HLL 'parrot'
.namespace [ 'TclArray' ]


.sub class_init :anon :load :init
  $P0 = get_class 'ResizablePMCArray'
  $P1 = subclass $P0, 'TclArray'
.end

.sub does :vtable
  .param string provides

 say "Checking..."

  if provides == 'foo' goto yes
  .return(0)
yes:
  .return(1)
.end




-- 
Will "Coke" Coleda


More information about the parrot-dev mailing list