Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - javascript - fix scalar assignment context under no-strict…
…; TODO cleanup; add reference to http://lwn.net/Articles/451486/
  • Loading branch information
fglock committed Aug 30, 2012
1 parent 3585bd8 commit 4b486e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
29 changes: 7 additions & 22 deletions TODO-perlito5
Expand Up @@ -37,6 +37,11 @@ TODO list for Perlito5
-- create __DATA__

-- "sub _" should be in package "main"
$ perl -MO=Deparse -e ' package X; sub _ { 123 } '
package X;
sub main::_ {
123;
}

-- "given" statement not implemented
-- "default" statement not implemented
Expand All @@ -53,6 +58,7 @@ TODO list for Perlito5
use Module $v; # $v is not accessible at compile-time

-- parse the regexes
-- create an AST for regexes

-- prototypes (signatures)
--- done: "empty" _ $ ;$
Expand All @@ -74,6 +80,7 @@ TODO list for Perlito5

-- 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
Expand All @@ -97,24 +104,6 @@ TODO list for Perlito5
-- lookup for existing subroutines:
sub m { my @x = 8, 9; @x } $x = m(); # m() is not a "match"

-- add globs for special variables:

wrong:
$ perl perlito5.pl -Cperl5 -e ' print *+ * 1'
(print() * +(*{'1'}));

right:
$ perl -MO=Deparse -e ' print *+ * 1'
use Tie::Hash::NamedCapture ();
print *+ * 1;
-e syntax OK
$ perl -MO=Deparse -e ' print *\ * 1'
print *\ * 1;
-e syntax OK
$ perl -MO=Deparse -e ' print */ * 1'
print */ * 1;
-e syntax OK


-- add tests for fixed bugs:

Expand Down Expand Up @@ -153,10 +142,6 @@ TODO list for Perlito5

* Javascript backend

-- bug: scalar assignment context:
$ node perlito5.js -Isrc5/lib -e ' @v = (4,7,9); $v = @v; print $v '
479

-- "~~" operator not implemented; See also "when" implementation

-- "when" should use a "break" exception inside "given", and a "next" exception inside "for".
Expand Down
3 changes: 3 additions & 0 deletions src5/lib/Perlito5/Javascript/Emitter.pm
Expand Up @@ -851,6 +851,9 @@ package Perlito5::AST::Var;
if ($sigil eq '@') {
$s = $s . ' || (' . $s . ' = [])'; # init
$s = 'p5pkg[' . $s . ', "' . $self->{namespace} . '"]["' . $table->{$sigil} . $str_name . '"]';
if ( $self->{sigil} eq '@' && $wantarray eq 'scalar' ) {
$s .= '.length';
}
}
elsif ($sigil eq '%') {
$s = $s . ' || (' . $s . ' = {})'; # init
Expand Down

0 comments on commit 4b486e0

Please sign in to comment.