On Mon, Sep 11, 2000 at 01:09:41PM -0400, [EMAIL PROTECTED] wrote:
> Currently I'm thinking C for the target compiler just because of its 
> ubiquity.

I don't think it matters much.  Any language similar to C (or C itself)
is fine.  The ticklish part is garbage collection, exceptions, and
the foreign language interfaces.

> As for the language we implement perl in (and thus ultimately need to 
> translate to the compiler-target language), I'm thinking of something like 
> Chip's PIL. (Or PIL itself--I've not actually seen it) Basically the 
> macro/tracking translator from hell that'll automagically generate header 
> files, provide all the permutations of vtable functions, and suchlike things.

As seen from here, the innovation of PIL is that it will be developed by
an evolutionary process.  The main complaint with perl5 that it is hard
to maintain, yes?  Why not attack the problem head-on?  Let's focus on
removing redundancy in the *current* perl5 source base.

+ Topaz attempted a *rewrite*.  Maybe Topaz was too ambitious.  Any kind
of code rewrite is going to take *years* before it can do anything.
Mythological "solve everything" type of projects frequently end prior to
completion.

+ Larry recently argued for developing perl6 in the same tarball as
perl5.  Admittedly, I am proposing to take a few steps further in this
direction.

Off the top of my head, here's what I might do next:

1. Select some source code from perl5.

2. Write a perl script to generate the source code.  Obviously, the
trival generator is:

#!./perl -w

print <<DONE;
..
DONE

However, we want a generator that separates the logical operations from
the C implementation language.  So I need a non-C domain specific
language and an C-language generator for it.  Maybe it would be
profitable to write two backends at the same time (C and something
else), to get a better abstraction.  The domain specific language might
be as simple as "english-ifying" the C source code.  For example:

SV**
Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval)
{
    SV *sv;

    if (!av)
        return 0;

    if (key < 0) {
        key += AvFILL(av) + 1;
        if (key < 0)
            return 0;
    }

    if (SvRMAGICAL(av)) {
        if (mg_find((SV*)av,'P') || mg_find((SV*)av,'D')) {
            dTHR;
            sv = sv_newmortal();
            mg_copy((SV*)av, sv, 0, key);
            PL_av_fetch_sv = sv;
            return &PL_av_fetch_sv;
        }
    }

    if (key > AvFILLp(av)) {
        if (!lval)
            return 0;
        sv = NEWSV(5,0);
        return av_store(av,key,sv);
    }
    if (AvARRAY(av)[key] == &PL_sv_undef) {
    emptyness:
        if (lval) {
            sv = NEWSV(6,0);
            return av_store(av,key,sv);
        }
        return 0;
    }
    else if (AvREIFY(av)
             && (!AvARRAY(av)[key]      /* eg. @_ could have freed elts */
                 || SvTYPE(AvARRAY(av)[key]) == SVTYPEMASK)) {
        AvARRAY(av)[key] = &PL_sv_undef;        /* 1/2 reify */
        goto emptyness;
    }
    return &AvARRAY(av)[key];
}

my ($av, $key, $lval) = 
  declare_interal_api('av_fetch', AV(), I32(), I32());
return_if_null($av);
open_condition($key, 'lt', 0, sub {
  advance($key, tmp_expr($av->fill, '+', 1));
  return_if($key, 'lt', 0);
});

# etc...

-- 
May the best description of competition prevail.
      (via, but not speaking for Deutsche Bank)

Reply via email to