> -----Original Message-----
> From: Dan Sugalski [mailto:dan@;sidhe.org]
>
> Okay, it's been a while, I've been out of it, it's time to start
> getting going.

Welcome back!

> Today's first topic: PMCs with real initializers. Here's a snip from
> the updated PDD2:
>
> --------------
>
> =item void init_pmc(INTERP, PMC* self, PMC* initializer)
>
> This form of the init method takes a single initializer parameter. The
> initializer is an array that contains keys and values. The meaning of
> the keys and their corresponding values is left up to the PMC.

Then I assume that the op "new_pmc" should be added which calls the init_pmc
vtable function? If so the patch in [perl #17811] should do the trick.

[snip]

> "Dimension", 3, "Color", "Green"]. Note that, in all cases, the array
> is an array of PMCs. (So you get either an int PMC or a string PMC in
> the list of keys)

Do you mean PerlInt and PerlString? Or do we want Int and String PMCs? In
the case of Sub PMCs an initializer could provide an address for the sub to
jump to which could look like this:

  #
  # build initializer
  #
  new P10, .Array
  set P10, 2

  new P11, .PerlString
  set P11, "address"

  new P12, .PerlInt
  set_addr I0, subroutine
  set P12, I0

  set P10[0], P11
  set P10[1], P12

  #
  # construct Sub using initializer
  #
  new P0, .Sub, P10
  invoke
  end

subroutine:
  print "in sub routine\n"
  ret

This seems tedious, but maybe I am missing the point? Anyway if this is what
we want the attached patch modifies sub.pmc to support this, and adds a test
to t/pmc/sub.t. This patch depends on [perl #17811].

--
Jonathan Sillito

Attachment: sub_init.patch
Description: Binary data

Reply via email to