TODO list for KindaPerl6 * Main Problems, unsorted - Perl 5 regex emitter - fix problem with delimiters inside code - fix code-blocks in regex - Longest token - implement an algorithm that we can use in the STD grammar - Strictness - undeclared vars are now looked up in GLOBAL::, and end up being autovivified - Pads in Perl 6 - see Scope.pm, Pad.pm - Threads, STM - Exceptions - this is needed by .for, in order to implement next, return - this is needed by 'try' - Junctions - needs fixing in the .APPLY method, should read the Code.signature - Eval string - this is needed by the current implementation of Pad.pm - Big integers - Lazy list - we have a partial implementation that does 'gather/take', infinite ranges - needs support for slices * Phase 5 "improved grammar" - foo(); sub foo() { say 'hi' } my &x; sub y { say 123 }; x(); BEGIN { &x := &y } - kp6-in-kp6 shows several problems with delimiter characters, because it emits code inside perl 5 regexes. One possible solution is to move code blocks into subroutines. - t/todo/grammar/15-capture-from-rule-block.t & t/todo/grammar/17-complex-return.t both go into infinite loops. misc/grammar_17_15_bug_ilustration.t - shows what causes the bug a PERL5 file that expresses this bug in a nice debuggable format is in - pugs/misc/pX/dlocaus/kp6-grammar-test-15.pl - good luck! * Phase 4 "improved runtime" - more TODO items are listed in the kp6-roadmap document - Assignment and Binding - (DONE) array x list, assignment and binding - expression-binding and parameter-binding should share the same code ($b, $a) := ( a => 1, b => 2 ); - untested: hash x array x scalar @a := $b; $b := @a; ... - (DONE) my @x = (1,2,3); say @x (DONE) {a => "b"}.{"a"} (DONE) {a => "b"}{"a"} # Pair LOOKUP - (DONE) move &say() to Prelude - (DONE) make [...] generate an Array object, (...) is List - (DONE) hyperops write tests - (DONE) undefined global variables are perl5 undef not perl6 Undef instances - Visitor::Namespace was implemented to correct this. - using Visitor::Namespace will require some refactoring in Runtime::Perl5::Global.pm - (DONE) remove KindaPerl6::Runtime::Perl5::DispatchSugar - (DONE) Autovivification - implement deep autovivification/laziness, such as $a[1][3].exists - this is needed by Namespace.pm, which implements namespaces in Perl 6 * Phase 3 "regex compiler refactoring" - (DONE) add command-line selection of plugins - add support for Perl5-PCR - add support for Parrot-PGE - improve kp6-regex - compile as MiniPerl6-in-Perl5 (redo bootstrap) - (DONE) - regexes should operate on $_ - separate runtimes/emitters: Perl5 (mp6), Perl5MO (kp6 phase 2), and Perl5Moose (v6.pm) - (DONE) - $List_COMPILER::PAD ("@COMPILER::PAD") should be $COMPILER::List_PAD instead * Phase 2 "improved compiler architecture" The kp6 Milestones are: - lexical subs - metamodel interface - bootstrap == kp6-2 - lexical classes - begin blocks - containers Starting Code freeze - translate perl5 runtime to mp6? - translate the compiler front-end to mp6 - test suite - debugging - minimal runtime - bootstrap? - plan Perl6-in-Perl6 The optional features in kp6 are: - coro - macro - multi - private method/sub/accessor - junctions - signatures with optional, named, slurpy arguments - a better parser - $?FILE, $?LINE - finer-grained error messages - precompilation - compiler cache - version checking - user-clonable closures - $closure.clone - creates new pads with copies of lexicals - lexically modifieable Grammar Incomplete features: + try(), eval() + 'Code' closure objects + 'Capture' objects + classes, methods, at compile-time + short-circuiting <&&>, <||>, (require macros, or laziness) - 'let' variables - 'our' variables - CATCH blocks - method hyperization is untested - binding does no type check - (DONE) all variables initialized during compilation should have initializers for run-time - traits - is context, rw, readonly - containers, but no laziness, no slices - hash and array are under refactoring - P6opaque - GLOBAL importation should be lexical - method not found falls back to sub call - lvalue methods (rw) - call context - type system - optimization phase - for-loop, map, with several arguments - (DONE) begin-blocks with side-effects - subroutine calls, data, are incompatible with perl 5 - no 'use v5' - declare our/state/temp/constant things - missing GLOBAL::import() at compile-time - 'our $x' should compile to 'my $x ::= $Pkgname::x' - 'use GLOBAL $x' should compile to 'my $x ::= $GLOBAL::x' - perl6-land 'use' - COMPILING::<$?PARSER> - translate the COMPILER package to mp6 - translate Pad.pm and Type.pm to mp6 - create an AST node for INIT/END BEGIN blocks: - (DONE) an anonymous subroutine is generated, but it is not called at runtime - logging of array/hash element modifications is not implemented - binding to Value is not emitted - Method and Class doesn't have '.perl' Bugs: - missing compile-time methods - (DONE) compile-time does not import GLOBAL - 'say' doesn't work inside BEGIN blocks - grammar: 'undefine($v)' is not parsed - structure binding/assign is untested Bootstrap: - add a switch for 'mp6 emulation', so that kp6 can be compiled efficiently using itself Roles: - (DONE) possible implementation: $Obj->{Role_bool} = sub { 1 }; at runtime: $Obj->{Role_bool} && $Obj->{Role_bool}() || $Obj->bool() - problem: objects based on p5-array (Array), p5-code (Code) - p5-land objects will only have Moose-based roles Optimization: - TODO Perl5 compatibility: - mark closure blocks as p5 or p6 (kp6/mp6) Problems running the Perl6 test suite: - (DONE) kp6 requires a 'compilation unit' declaration - '&&', '||' operators don't short circuit there is a workaround, but this should really be implemented using macros - (DONE) 'if', 'sub' require ';' - postfix:<++> not implemented - 'use' doesn't accept parameters: use lib "."; - parameter list error in: if defined $var { ... requires: if defined($var) { ... - no END blocks Visitor modules: - deprecated modules: KindaPerl6::Visitor::LexicalSub KindaPerl6::Visitor::CreateEnv - (DONE) add variable declarations collector -- XXX now obsolete! - move variable declarations to the start of each block - LexicalSub.pm -- XXX now obsolete! - add 'our' subs to the namespace, if there is one - verify the interface with native p5 subs, such as 'Main::say' - only create a "lexical sub" call if the sub is in scope - MetaClass.pm - add class variables - test bootstrap - roles - create BUILD, BUILDALL Other: - (DONE) star/GLOBAL namespace zzz() --> ($_SUB_zzz || $GLOBAL::_SUB_zzz)->(@args) $*foo --> $GLOBAL::foo but: TimToady> under strict there is no fallback to global unless you explicitly import (you also get a snapshot of GLOBAL imported automatically at the start of compilation) - what are the differences between compiling modules and compile plain-programs - OUTER namespace - ROUTINE - tail-calls For later: - desugar blocks into real subroutines, in support for the parrot backend - fixed by now, using p6parrot as an intermediate language - desugar closures into simple subroutines, in support for the C backend - temp/state desugaring, for perl5 - 6-on-6 design - full-ast - some of the ast can be desugared into runtime method calls - optimizations may require a much detailed ast, but this detailed ast is probably backend-specific - Directory structure - compiled x source + src* + compiled + lib* - main level + lib + script + t * lib * Kp6 + Compiler + Runtime - second level * lib * Kp6 * Compiler + FrontEnd + Grammar (or "Language") + AST + Emitter (or "Target") * Runtime + Kp6 + Parrot + Perl5 - expanded * lib * Kp6 * Compiler * FrontEnd * Cache * Grammar * Perl6 * Regex * Quote * Macro * Variable * AST * Perl6 * Hyper * MetaClass * Regex * Quote * Macro * Variable * Emitter * Kp6 * Parrot * Perl5 * Runtime * Kp6 * Match * Pad * Type * Parrot * Perl5