Closed yuki-kimoto closed 11 years ago
We are following what Perl 6 does here. Also I don't think that $:foo could be a valid twigil.
p5-mop is Perl5 project, not Perl6. I don't understand the meaning that "We are following what Perl 6 does here".
Yuki - the idea is to keep as much compatibility with Perl 6 as possible.
OK.
By the way, Dose twigil work well in Perl5? For example, Dose the following code work well?
"$!title"
$! is special variable. How to distinguish these cases?
Right now the twigil module is a bit of a hack with the parser, it basically finds $! and then looks ahead to see if there is a bareword after it, if there is, it interprets it as a twigil. If it becomes part of the core, then it will most certainly become a proper part of the parser.
If it don't work in lexical scope, backward compatible is broken. The change maybe denied from core team. Can twigil work in only lexical scope?
Yes, it works in lexical scope (as well as our
and state
scope). If the change is denied by the core team we will go back to regular variables ($foo
as opposed to $!foo
).
If attribute foo is private variable, we can also use the name $_foo to prevent crash variable names. If attribute name crash lexical variable, we can use accessor.
has $x is rw;
has $_y;
method foo {
my $x;
my $y;
if ($x eq $self->x) {
}
if ($_y eq $y) {
}
}
I think even if twigil is denied, mop don't have big trouble. And you can also think twigil as next step of mop.
Yes, these are the techniques I used when I ported Plack, but honestly they are not nearly as nice as the twigil.
I think twigil exclamation mark ! is a little difficult to read.
In Perl, ! mean "deny". And ! is often used.
What about other mark?