Below inline/attached is a proposal for Parrot core changes. I'll post a more detailed proposal for 1) objects in a minute.

leo
Proposed steps towards the next release 0.2 and beyond.

These are numbered just for reference but are else in no particular
order. A lot can be done in parallel. A lot needs more refinement and
discussion. And *some* should be approved by Dan.

Not all will be finished for 0.2 but I hope a lot.

As this is a pretty long list I'll start distinct threads with more
details and a rationale. Follow up's should go there.

1) objects

1.1) split C<dispatch> from C<find_method>
   - find_method ... check if the class can do the method
   - dispatch    ... do the full method lookup, possibly MMD

1.2) new C<mro> array
   - array of classes in canonical method resolution order

2) vtables

2.1) all implemented vtable and MMD slots in one class become
   NCI methods.

2.2) the vtable entries get split into "roles"

   struct _vtable {
     init, destroy, hash, mark, class,
     ...                         // common, main part
     Vtbl_scalar*as_scalar;      // abs, not, int, num, ...
     Vtbl_...   *as_native_scalar// get_integer, set_integer_native, ...
     Vtbl_array *as_array;       // get_pmc_keyed, push, pop, ...
     Vtbl_...   *as_native_array // get_integer_keyed, ...
     Vtbl_hash  *as_hash;        // exists_keyed, ...
     ...        *as_native_hash; // get_integer_keyed_str, ...
                *as_iterator;    // get_next, ...
                *as_object;      // get_attribute, ...
     ...
   };

3) function and method signatures

3.1) *the object is passed to methods as the first argument*

3.2) *change to calling conventions needed*

  multi sub foo(int $a, float $b) {...}
  multi sub foo(float $a, int $b) {...}

    set I5, x
    set N5, y
    invokecc "foo"     # now what?

3.3) *need per scope register frames* for timely destruction

4) more vtables

4.1) new vtable methods that return a new destination PMC

   add dest, l, r        # use existing dest PMC
   n_add dest, l, r      # create new dest PMC

4.1.1) implement a language pragma in assembler, e.g.:

  .HL_language Python

4.1.2) create table of canonical types per language mapping

  Integer - PyInt - TclInt - Perl6Int - ...

4.2) separate inplace operations from infix operations

   dest += r        <=>   dest."__i_add"(r)

4.3) misc new vtables:
  - coerce, hash, get_numeric, ...
  - new PMC variants of exisiting vtables

5) fix MMD and vtable operator inheritance

5.1) implement MMD dispatcher

5.2) Parrot infix operator equivalence:

"You are in a maze of twisty little passages, all alike.":

   add d, l, r
   d = add l, r
   d = l + r
   d = l."__add"(r)
   d = "__add"(l, r)

are all the same.

And probably:

  .use n_operators
  ...
  d = l + r      <=>      d = l."__n_add"(r)

5.3) use dynamic dispatch for prefix/postfix too

For PMC operands, these are all the same:

   abs d, a
   d = abs a
   d = a."__abs"()
   d = "__abs"(a)

6.) create list of builtins

All function-like PMC-related opcodes become methods in some namespace

6.1) create appropriate namespaces, e.g.

   sin x, y        <=>   x = Math."__sin"(y)     # PMC
   sin N0, N1      # native float variant remains
   getstdin Px     <=>   Px = IO."__getstdin"()
   sweep 1         <=>   GC."__sweep"(1)
   split a, d, s   <=>   a = String."__split"(d, s)  # if d isa String
                   <=>   a = d."__split"(s) # generally

The translation is done by the assembler according to the list of builtins
so that the current syntax remains valid.

7) *new PMC layout*

7.1) *PMCs become variable sized*

7.2) *the STRING* type becomes an alias for the String PMC*

7.3) *a Buffer becomes kind of a CharArray PMC* - if we still need a Buffer

8) simplify Hash PMC

8.1) get rid of movable Hash buffers

8.2) get rid of indirection through BucketIndex

9) redo iterators

9.1) iterator vtables

  - get_iter vtable (is ok)
  - iter_next vtable - replaces current next_xx_keyed/shift sequence

9.2) an iterable implements C<get_iter>
     an interator can C<iter_next>

9.3) fix slice, range, xrange, ... iterators

10) Last but not least

10.1) continue work on unicode, strings, building & installation, GC,
   libraries, threads, events, ...

10.2) new things like the Version PMC, async IO, and what not.

Reply via email to