Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make method postcircumfix:<* *> and method <sigil> obsolete
We probably want a custom typed_worry for the postcircumfix case.
  • Loading branch information
Mouq committed Mar 7, 2015
1 parent 727f96f commit b57f135
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
36 changes: 26 additions & 10 deletions src/Perl6/Actions.nqp
Expand Up @@ -2765,6 +2765,19 @@ class Perl6::Actions is HLL::Actions does STDActions {
$*W.apply_trait($/, '&trait_mod:<is>', $code, inlinable => $inline_info)
}

my %deprecated_postcircumfix := nqp::hash(
'[ ]', 'AT-POS, ASSIGN-POS, or BIND-POS',
'{ }', 'AT-KEY, ASSIGN-KEY, or BIND-KEY',
'( )', 'invoke', # INVOKE…
);
#my %deprecated_methodname := nqp::hash(
# 'at_key', 'AT-KEY',
# 'assign_key', 'ASSIGN-KEY',
# 'bind_key', 'BIND-KEY',
# 'at_pos', 'AT-POS',
# 'assign_pos', 'ASSIGN-POS',
# 'bind_pos', 'BIND-POS',
#);
method method_def($/) {
my $past;
if $<onlystar> {
Expand All @@ -2791,8 +2804,15 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
if $ln<colonpair>[0]<coloncircumfix> -> $cf {
if $cf<circumfix> -> $op_name {
$name := $name ~ '<' ~ $*W.colonpair_nibble_to_str(
$ln, $op_name<nibble> // $op_name<semilist> // $op_name<pblock>) ~ '>';
my $circumfix := $*W.colonpair_nibble_to_str(
$ln, $op_name<nibble> // $op_name<semilist> // $op_name<pblock>);
my $fullname := $name ~ '<' ~ $circumfix ~ '>';
if $name eq 'postcircumfix:' && my $depr := %deprecated_postcircumfix{$circumfix} {
$/.PRECURSOR.worryobs("method $fullname",
"method $depr, or use sub postcircumfix:<$circumfix>",
"to represent $circumfix delegation");
}
$name := $fullname;
}
else {
$name := $name ~ '<>';
Expand All @@ -2802,14 +2822,10 @@ class Perl6::Actions is HLL::Actions does STDActions {
else {
my $longname := $*W.dissect_longname($<longname>);
$name := $longname.name(:dba('method name'), :decl<routine>);
}
}
elsif $<sigil> {
if $<sigil> eq '@' { $name := 'postcircumfix:<[ ]>' }
elsif $<sigil> eq '%' { $name := 'postcircumfix:<{ }>' }
elsif $<sigil> eq '&' { $name := 'postcircumfix:<( )>' }
else {
$/.PRECURSOR.panic("Cannot use " ~ $<sigil> ~ " sigil as a method name");
# XXX Tries to warn when compiling CORE.setting
#if my $depr := %deprecated_methodname{$name} {
# $/.PRECURSOR.worryobs($name, $depr);
#}
}
}
$past.name($name ?? $name !! '<anon>');
Expand Down
14 changes: 13 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -2712,7 +2712,19 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
| '[' ~ ']' <multisig>
| '{' ~ '}' <multisig>
]:s
<trait>*
{
my $brackets;
if $<sigil> eq '@' {
$brackets := '[ ]';
} elsif $<sigil> eq '%' {
$brackets := '{ }';
} elsif $<sigil> eq '&' {
$brackets := '( )';
} else {
$/.CURSOR.panic("Cannot use " ~ $<sigil> ~ " sigil as a method name");
}
$/.CURSOR.sorryobs('method '~$<sigil>~'.( )', "sub postcircumfix:<$brackets>", "to overload $brackets");
}
| <?>
]
{
Expand Down

0 comments on commit b57f135

Please sign in to comment.