Skip to content

Commit

Permalink
Implement 'use MONKEY_TYPING'; augment and supersede are now forbidde…
Browse files Browse the repository at this point in the history
…n without it. Infinitesimally small chance of entire works of Shakespeare being written as a side effect.
  • Loading branch information
jnthn committed Mar 13, 2010
1 parent a078e49 commit 3ddd002
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -394,6 +394,9 @@ method statement_control:sym<use>($/) {
),
);
}
elsif ~$<module_name> eq 'MONKEY_TYPING' {
$*MONKEY_TYPING := 1;
}
else {
need($<module_name>);
import($/);
Expand Down
6 changes: 5 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -85,7 +85,10 @@ method add_our_name($name) {
method add_name($name) {
if $*SCOPE eq 'augment' || $*SCOPE eq 'supersede' {
unless self.is_name($name) {
pir::die("Can't $*SCOPE something that doesn't exist");
pir::die("Can't $*SCOPE $*PKGDECL that doesn't exist");
}
unless $*MONKEY_TYPING {
pir::die("Can't $*SCOPE $*PKGDECL $name without 'use MONKEY_TYPING'");
}
}
else {
Expand Down Expand Up @@ -239,6 +242,7 @@ token comp_unit {
:my %*METAOPGEN; # hash of generated metaops
:my $*IN_DECL; # what declaration we're in
:my $*IMPLICIT; # whether we allow an implicit param
:my $*MONKEY_TYPING := 0; # whether augment/supersede are allowed
<.newpad>
<.outerlex>
<.finishpad>
Expand Down
4 changes: 4 additions & 0 deletions src/core/traits.pm
@@ -1,3 +1,7 @@
# Need to be able to augment in the setting, and this is the first file, so we
# put this here.
use MONKEY_TYPING;

# XXX Signature is wrong really - will fix once we can parse other things.
our multi trait_mod:<is>(Mu $child, Mu $parent) {
$child.^add_parent($parent);
Expand Down

0 comments on commit 3ddd002

Please sign in to comment.