Day 206: Updates on JavaScript and Perl5 runtimes.

autrijus on 2005-08-31T19:53:39

Starting last week, there's an effort to combining common infrastructure and design for the JavaScript runtime and the Perl5 runtime, headed by iblech and fglock respectively, with plenty of help from putter at both sides.

To that end, putter added a new magical $?PUGS_BACKEND variable to track the codegen used. He also added backend-specific make test targets: `make test-js, make test-perl5, make test-pir, and make test-all` to run for all backends. Same applies to make smoke, too.

If you want to track the progress on all our runtimes, check out iblech's Pugs Smoke Reports page It's now linked from Pugs's homepage; smoke testers are encouraged to submit smoke.html there. Below is a few of selected news on JS and Perl5 backends -- I still had not backlogged through all relevant changes, let alone other changes in the Haskell runtime...

JavaScript

  • Passing 3954/5117 subtests, 70 unexpected successes, 77.27% OK.
  • Of the ext/ modules, Algorithm::TokenBucket now runs correctly in addition to Test.pm.
  • Much more extensive README with implementation details.
  • Perl5-compatible regular expression support via JavaScript-side PCRE, including captures.
  • &?CALLER_CONTINUATION works fully, thanks to the codegen's CPS transform, marking the first runtime that support reentrant call/cc correctly.
  • Support for coroutines via coro and yield.
  • Flow controls, including next, last, redo as well as postfix while and until.
  • Container equivalence test =:= distinguished from object identity test eqv.
  • Correct semantics for reference to containers and auto-enreferencing arrays/hashes to refs.
  • Restored junctive autothreading support.
  • Slurpy hashes and arrays, which according to the latest ruling can't be passed in by name now.
  • A new Perl5 module, Perl6::Run::JS, that wraps JavaScript::SpiderMonkey to work as an alternative runtime to bin/js and HTML browsers. This allows for mixed Perl6/Perl5 code to work even with the JavaScript codegen.
  • (1,2,3) no longer allocates new containers, the way [1,2,3] does.
  • UTF8 support for both bin/js and browsers.
  • The CALLER:: pseudo package, as well as symbolic deference based on that.
  • A new command: :e exp, for evaluating an expression in the interactive jspugs.pl shell.
  • Fully qualified code variables such as &foo::bar() no longer autovivify to no-op, as it still is in the Haskell runtime.
  • Emulated &sleep support by burning CPU, for SpiderMonkey which has no setTimeOut builtin.
  • Simple list binding, eg. ($a, $b) := ($b, $a). Full subroutine-param syntax is not yet there.
  • LValue subs (sub is rw) emitted as PIL and compiled directly to JS.
  • Support for temp and let declarations.
  • Macros for JS written in Perl5 via PIL::P5Macro; part of Prelude::JS is now written that way.

Perl5

  • Test.pm does not yet run correctly, so sanity tests are the only tests that pass.
  • All builtin classes migrated to use MetaModel 1.0, allowing full reflection from user space.
  • Primitives can now be written as Perl5 macros in PIL::Run::PrimP5, as well as in Perl6 with PrimP6.pm.
  • Support for read-only variables, which can only be assigned once: eg. my $x is readonly; $x = 3 (this replaces the old is constant trait.)
  • Scalar containers handles autoderef/autoenref, binding and tieableness correctly.
  • Hash containers is now based on Perl6::Container::Hash::Object, allowing any object to potentially serve as hash keys.
  • Array containers are now fully sparse, allowing for efficient storage like [ 1, undef x 1_000_000, 2 ].
  • Support for lazy Array slices; all destructive updates to Array preserve as much laziness and sparseness as possible. For example, @a = 1..9999999; @a[1..1000000] = @a[1000001..2000000] would take constant time.
  • Ref class, with autodereferncing when pointing to Array or Hash container objects.
  • Pair class, with the => constructor and stringification.
  • Code class, with Sub, MultiSub and Block exposed as Perl6 classes.
  • Invoking Perl6's Code objects in Perl5 now carries over slurpy (i.e. wantarray) context information.
  • Various primitives, including basic variable manipulations, anonymous array/hash, list constuction, coercion and arithmetics.
  • Inline::Pugs hooked to Perl5 runtime. This now works without spawning off a separate process:
    use Inline Pugs => q{
        sub intone { say "Hello, $_!" }
    };
    intone('World');

Whew. That was a lot. To be continued tomorrow...