On Fri, Jun 18, 2010 at 11:21:52AM +0200, Jan Ingvoldstad wrote:
: On Fri, Jun 18, 2010 at 11:15, Smylers <smyl...@stripey.com> wrote:
: > For the benefit of Perl 5 programmers used to string reverse it would be
: > nice to have a warning if reverse is invoked with exactly one string
: > argument (but not with an array which happens to contain a string as its
: > only element).
: Perhaps if one uses a "use P5warnings" or something?
: Such warnings can become quite awful as Perl 6 grows and matures.
It's hard to know how to do that. If you make it the default to not
warn, then the people who really need the warnings will almost never
turn them on. If you make it default to warn, then people will have to
turn off the warnings forever.
In this particular case, I think there's little chance of
my $x = "foo";
happening by accident in a well-formed P6 program, so it's probably
okay to always warn. However, we do have warnings that are more
in the category of "irritating to P6 programmers", such as:
Leading 0 does not indicate octal in Perl 6 at foo line 2
You almost want one of those little persistent registry-ish flags
that records the user's estimated level of expertise...
Almost, but not quite.
At the moment I'm thinking of a mechanism whereby you can suppress
warnings inline, and maybe there should be an emphatic form that
suppresses it for the rest of the program. Something like
0123; # warns
0123; # ok! # suppresses this warning here
0123; # OK! # suppresses this warning from now on
Though I'm hesitant to use comment syntax for that. A statement
prefix might be more appropriate. We've currently reserved "quietly"
for simple run-time warning suppression, but that's kinda long, and
not defined for compile-time warnings yet. Admittedly, it would be
rather amusing to have to shout at Perl 6 to make it shut up:
my $x = QUIETLY 0123;