Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: c701f67a20
Fetching contributors…

Cannot retrieve contributors at this time

505 lines (342 sloc) 13.724 kB
TODO list for Perlito5
* perlito5 command-line
* libraries
-- these should probably go into namespace Perlito5X::*
-- Test (implemented as Perlito5::Test)
-- Data::Dumper (implemented as Perlito5::Dumper)
-- create perlito5-specific libs for:
feature.pm
Config.pm
overload.pm
bytes.pm
integer.pm
constant.pm
lib.pm
Carp.pm
vars.pm
Tie::Array
Tie::Hash
Tie::Scalar
alternately, check $^H for strictness - such that perl's own strict.pm just works
and ${^WARNING_BITS} for warnings
* Parser
-- dot-decimal strings
5.4.66.77
v5.4.66.77
$ perl -e ' my $v = 5.4.66.77 ; print $v, "\n"; require $v '
BM
-- "'" meaning "::"
$'m # $::m
$m' # String found where operator expected
package X'Y # X::Y
package X' # Invalid version format (non-numeric data)
-- attributes
http://perldoc.perl.org/attributes.html
missing MODIFY_CODE_ATTRIBUTES handlers
-- create __DATA__
%Perlito5::DATA_SECTION contains the __DATA__ for each package
-- compile-time eval() is not bound to the "program" environment, but to the "compiler" environment instead
see README-perlito5-js near "Compile-time / Run-time interleaving"
my $v;
BEGIN { $v = "123" }
use Module $v; # $v is not accessible at compile-time
-- parse the regexes
create an AST for regexes
-- prototypes (signatures)
http://perldoc.perl.org/perlsub.html#Prototypes
check that undeclared barewords give the right error
*foo = sub () { ... } # does prototype work here?
check signature in sort()
fix the prototype for 'stat(*)' (see t/test.pl in the perl test suite)
-- "namespace" parsing
tests: t5/01-perlito/26-syntax-namespace.t
$ perl -e ' { package X; sub print { CORE::print(">$_[1]<\n") } } my $x = bless {}, "X"; print $x "xxx" '
Not a GLOB reference at -e line 1.
$ perl -e ' { package X; sub printx { CORE::print(">$_[1]<\n") } } my $x = bless {}, "X"; printx $x "xxx" '
>xxx<
$ perl -MO=Deparse -e ' print X:: "xxx" '
print X 'xxx';
$ perl -e ' use strict; my $x = X::; print $x '
X
$ perl -e ' use strict; my $x = X; print $x '
Bareword "X" not allowed while "strict subs" in use
$ perl perlito5.pl -MO=Deparse -e ' ::X::x::y '
join("", ::{'main::X::'} x main::y);
$ perl -MO=Deparse -e ' ::X '
'???';
$ perl -MO=Deparse -e ' sub X {} ::X '
sub X { }
X;
$ perl -e ' $::X::::X = 3; print $main::X::::X ' # 3
$ perl -e ' $::X::::X = 3; print $main::main::X::::X ' # 3
$ perl -e ' $::X::::X = 3; print $main::X::main::X ' # empty
$ perl -e ' $::X::::X = 3; print $main::X::X ' # empty
$ perl -e ' $::X::::X = 3; print $::::X::::X ' # empty
-- CORE:: namespace can be used with operators:
$ perl -MO=Deparse -e ' $x CORE::and $v '
$v if $x;
$ perl -MO=Deparse -e ' @v = CORE::qw/ a b c / '
@v = ('a', 'b', 'c');
$ perl -MO=Deparse -e ' $x CORE::+ $v '
CORE:: is not a keyword
-- strict and warnings: create options like 'subs', 'refs'
-- clean up:
the several "end_tables" in Expression.pm are duplicating the function of
$Precedence in Precedence.pm - Expression.pm should use $Precedence directly.
-- things that work in perlito5, but which are errors in 'perl'
$ perl -e ' my @things= map { no warnings; 123 } @list; '
"no" not allowed in expression
quotes vs. hash lookups:
$ perl -e ' q}} '
# ok
$ perl -e ' $x{ q}} } '
Unmatched right curly bracket at -e line 1, at end of line
$ perl -e ' $x{ q]] } '
# ok
string interpolation with nested quotes of the same type:
$ perl -e ' " $x{"x"} " '
String found where operator expected at -e line 1, near "x"} ""
* Add tests for fixed bugs:
---
variable declarations in expressions
our $Verbose ||= 0;
our (%Cache);
my $args = @_ or @_ = @$exports;
---
add additional variants of "for"
# "our" with localization
$ perl -e ' use strict; our $x = 123; for our $x (1,2,3) { 2 } print "$x\n" '
123
# variable in scope with localization
$ perl -e ' use strict; my $x = 123; for $x (1,2,3) { 2 } print "$x\n" '123
123
---
add "print", "printf", "say" special parsing - note this is related to indirect object notation
indirect object notation
http://lwn.net/Articles/451486/
http://www.modernperlbooks.com/mt/2009/08/the-problems-with-indirect-object-notation.html
http://shadow.cat/blog/matt-s-trout/indirect-but-still-fatal/
http://perlbuzz.com/mechanix/2008/02/the-perils-of-perl-5s-indirect.html
method Module $param;
new Class( arg => $value );
new Class::($args);
say $config->{output} "This is a diagnostic message!"; # indirect call
say {$config->{output}} "This is a diagnostic message!"; # say to filehandle
use Class;
sub Class {
warn 'Called Class sub not Class package';
'Class'
}
my $q = Class->new; # calls the Class sub above
my $s = new Class; # throws a 'Bareword found where operator expected' error
my $t = Class::->new # this works
my $u = new Class::; # this also works (even with sub main in the current package)
sbertrang++ noted this is also valid:
print( STDERR "123" )
---
add tests for signatures: "empty" _ $ ;$
---
add test for "sub _" should be in package "main"
$ perl -MO=Deparse -e ' package X; sub _ { 123 } '
package X;
sub main::_ {
123;
}
---
add test for defined-or vs. m// (2012/9/25 Конрад Боровски <notifications@github.com>)
Note: fixed; see test t5/01-perlito/25-syntax-defined-or.t
$ perl perlito5.pl -Isrc5/lib -Cast-perl5 -e ' shift // 2 '
Number or Bareword found where operator expected
$ perl perlito5.pl -Isrc5/lib -Cast-perl5 -e ' shift / 2 '
Can't find string terminator '/' anywhere before EOF
---
add test for filetest operators special case:
' -f($file).".bak" ' should be equivalent to -f "$file.bak"
parses as -(f($file)).".bak"
but: ' -f ($file).".bak" '
parses correctly
This seems to be because there is a rule that \w followed by '(' is a function call;
this needs more testing: ' ... and(2) '
Test: redefine 'and', 'not' and check what works.
' $s111++ + $s222 '
parses as (+$s222)++
' $step++ < $steps '
Can't find string terminator '>' anywhere before EOF
-- from moritz, Schwern and others at
http://stackoverflow.com/questions/161872/hidden-features-of-perl
- you can use letters as delimiters
$ perl -Mstrict -wle 'print q bJet another perl hacker.b'
Jet another perl hacker.
Likewise you can write regular expressions:
m xabcx
# same as m/abc/
* Perl5 backend
-- "given" statement not implemented
-- "default" statement not implemented
-- check that \(@a) and \@a have different meanings
-- ${^NAME} needs curly-escaping
- fix regex delimiters, or escape the regexes
-- continue block in block: ' { print 1 } continue { print 2 } '
-- emitter bug: significant parenthesis:
t5/01-perlito/12-context.t fails because:
" return (4, 5) " instead of " return 4, 5 "
-- bug: ' $$x [$y] '
emits as ${$x}->[$y];
* Javascript backend
-- autovivification of fully-qualified array and hash globals
$#{"Exporter::Cache"};
${"Exporter::Cache"}[2] = 3;
See: p5scalar_deref() / p5scalar_deref_set() in Perlito5/Javascript2/Runtime.pm
-- pass @_ to &sub
$ node perlito5.js -I./src5/lib -Cjs -e ' @_ = (1,2); &foo; '
# call foo(@_)
-- dot-decimal strings / v-strings
$ perl -e ' my $v = 5.4.66.77 ; print $v, "\n"; require $v '
BM
-- variable declarations inside condition
if ((my $color = <STDIN>) =~ /red/i) {
$value = 0xff0000;
}
elsif ($color =~ /green/i) {
$value = 0x00ff00;
}
else { ... }
After the else, the $color variable is no longer in scope.
-- do {} while / do {} until
execute the loop once, before checking the condition
-- 'require v5.006;'
# Can't locate v5.006 in @INC
-- expressions in 'local'
local $SIG{__WARN__};
-- assign old-self to my / local
local $Some_Global = $Some_Global;
-- 'next', 'last' in expression
(*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}, next)
... ) and last
-- 'x' in list context
@{$cache}{@$ok} = (1) x @$ok;
-- '&' prototype
add tests; see Try::Tiny
-- AUTOLOAD() called from UNIVERSAL autovivifies packages
add tests
-- prototype() can be set by aliasing:
*x = sub ($$) { 123 }; *y = *x; print prototype(\&y) # $$
-- check that \(@a) and \@a have different meanings
-- delete() in the middle of an array turns exists() off:
$ perl -e ' @a = (3..7); delete $a[2]; print "exists ", (exists $a[$_] ? 1 : 0), "\n" for 0 .. $#a '
exists 1
exists 1
exists 0
exists 1
exists 1
-- "or" has SCALAR context (Abigail++):
See: t5/01-perlito/23-eval.t
-- "~~" operator not implemented; See also "when" implementation
-- "given" statement not implemented
-- "when" should use a "break" exception inside "given", and a "next" exception inside "for".
-- "default" statement not implemented
-- bug: some declarations are not "seen":
for ( my $i = 0; $i < 10 ; $i++ ) { print "$i\n" } # compiles to global $i
-- bug: don't emit throw() in term position; javascript requires a function() wrapper because throw() is a statement
-- javascript errors don't show in the global error handler when running in node.js
-- "autoload" the compiler if eval-string is used (eval-string needs the compiler at run-time)
-- symbol variables like $] ${"main::\$"} $#_
-- check that @_, $_, $a, $b and other special variables are in the right context (lexical, global, package global)
-- add alternate mro's
-- cache the mro
-- add regex compiler
-- /e modifier
-- /x modifier
-- support all perl5 regex syntax
-- @v = /x/g
-- bug: variable redeclaration does not work
-- javascript "var" erases the outer value within the whole current lexical scope
-- bug: "my" variables - this doesn't work as expected: my $v = $v
possible fix: rename variables
-- lvalue ternary: ($a_or_b ? $a : $b) = $c;
-- lvalue substr()
-- 4-arguments substr()
-- pos($str)
-- lvalue chomp(), chop()
-- missing some types of subroutine signatures
-- bug: variable aliases create copies instead
-- generate more compact code; maybe use more subroutines instead of inlining;
autovivification is probably the most verbose part of the code.
-- in the browser: implement "use" with XMLHttpRequest (what are the security implications?)
-- add symbol tables for scalar, array and hash
-- references to typeglobs:
$ perl -e ' print ref(\*main) '
GLOB
-- aliasing between lexicals and globals
$ perl -e 'use strict; my $x = 3; *main::z = \$x; print $main::z; '
3
-- string increment and string ranges
See: p5str_inc()
-- finish "overload" implementation
-- pack(), unpack()
-- y()()
-- BEGIN{} should execute in the environment of the program under compilation
-- BEGIN/END that are defined inside blocks/closures need to run inside some pseudo-environment
even if the closure was never created or used in the first place
-- bug - method call context is disabled, because it breaks bootstrap.
in Runtime.pm:
function p5call(invocant, method, list, p5want) {
list.unshift(invocant);
p5want = 0; // TODO BUG - workaround for broken bootstrap
-- bug https://github.com/fglock/Perlito/issues/10
"Perlito 5 JS has syntax errors"
Tried
YUI Compressor online
and
Google Closure Compiler
http://closure-compiler.appspot.com/home
Both failed with syntax errors.
-- flip-flop operator
if either operand to scalar '..' is a constant the value is implicitly compared to the input line number ($.)
-- unary minus on strings.
my $_ = "a"
print -$_
# -a
my $foo = '-bar';
print $foo;
print -$foo;
# -bar+bar
* Nice to Have
-- debugging symbols
-- line numbers in error messages
-- caller()
-- "when"
-- run more of the "perl" test suite
-- proper "use strict" and "use warnings"
-- use the same error messages and warnings as 'perl'
-- no warnings 'redefine';
-- __LINE__, __FILE__
-- INIT{}, END{}
look at the implementation in perlito6-in-Go
-- source code - remove Perl 6 code such as "token"
(fixed: This is only loaded if the grammar compiler is needed)
-- *{ $name }{CODE}->();
-- local(*{$caller."::a"}) = \my $a;
-- *{$pkg . "::foo"} = \&bar;
* Oddities
-- from moritz, Schwern and others at
http://stackoverflow.com/questions/161872/hidden-features-of-perl
- you can give subs numeric names if you use symbolic references
$ perl -lwe '*4 = sub { print "yes" }; 4->()'
yes
-- The "desperation mode" of Perl's loop control constructs which causes them to look up the stack to find a matching label allows some curious behaviors which Test::More takes advantage of, for better or worse.
SKIP: {
skip() if $something;
print "Never printed";
}
sub skip {
no warnings "exiting";
last SKIP;
}
* Deprecate
-- remove unused features from src5/lib/Perlito5/Grammar/Regex.pm
-- Interpreter backend
this is not being maintained; the code is still in src5/lib/Perlito5/Eval.pm just in case
-- Perl6 backend (started)
this is not being maintained; not sure if compiling to Perl6 is the best way
maybe compiling directly to Parrot/dotnet/Haskell gives better results
Jump to Line
Something went wrong with that request. Please try again.