Re: Something wrong with str.reverse
Warning on using any list-y op on a scalar seems like a good idea, and the fact that the idea arose after a perl5 misunderstanding now looks like a "red herring". That is, while warning on "only" reverse-on-a-scalar may be a bad idea and perl5 specific, I'd vote for warning on all apparent mis-uses of list ops on scalars as a generally helpful.
Re: Something wrong with str.reverse
On Mon, Jun 21, 2010 at 10:47, Smylers wrote: > Larry Wall writes: > > > On Fri, Jun 18, 2010 at 11:21:52AM +0200, Jan Ingvoldstad wrote: > > > > : On Fri, Jun 18, 2010 at 11:15, Smylers 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. > > I was only thinking about that specific warning, not generally warnings > that might be of use to Perl 5 programmers. And I don't see how warning > about calling reverse on a scalar would be awful. > > It isn't something that makes sense to do (it's a no-op), and it isn't > just former Perl 5 programmers who might make that mistake; anybody who > does could be warned about it. > And that's my beef, really: adding warnings that are useful because of the language itself is quite unproblematic, but adding warnings for the sake of those who move from other languages -- even within the same family -- /can/ become awful. They don't necessarily have to be, but I would advise utmost caution. Also, it's important that there is consistency and consecution in warnings. As pmichaud++ mentions in a followup response, there are several other cases where warnings are not issued. A rational consequence of adding a warning for .reverse used on string, is to add a warning for other cases where it does not make sense (but which may come as a surprise), and equally for the other cases (see pmichaud's list) where built-in methods may be invoked by a similar misunderstanding. Anyway, these are merely my personal opinions, I like to express them from time to time, but I don't call the shots any more than you do! -- A sextuple-acrostic post by Jan ;)
Re: Something wrong with str.reverse
On Mon, Jun 21, 2010 at 09:47:37AM +0100, Smylers wrote: > Larry Wall writes: > > On Fri, Jun 18, 2010 at 11:21:52AM +0200, Jan Ingvoldstad wrote: > > : On Fri, Jun 18, 2010 at 11:15, Smylers 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). > > : > > : Such warnings can become quite awful as Perl 6 grows and matures. > > I was only thinking about that specific warning, not generally warnings > that might be of use to Perl 5 programmers. And I don't see how warning > about calling reverse on a scalar would be awful. > > It isn't something that makes sense to do (it's a no-op), and it isn't > just former Perl 5 programmers who might make that mistake; anybody who > does could be warned about it. On the other hand, many of our other list-y methods also work on scalars (treating them as a list of 1 element -- essentially a no-op): .join, .sort, .any, .all, .rotate, .max, .min, .pick, .reduce, .values, etc. It might be inconsistent that .reverse on a scalar warns when the others do not. Personally, I'm fine with .reverse issuing a warning when it appears on a scalar, but doing so will be inconsistent with the pattern of the other list methods on scalars. Pm
Re: Two questions on Perl 6 functionality
Xi Yang wrote: > You might mis-understood method modifiers. I mean: > before x() > after x() > around x() > In Perl 6, you do that with wrapping: http://perlcabal.org/syn/S06.html#Wrapping Cheers, Moritz
Re: Something wrong with str.reverse
Larry Wall writes: > On Fri, Jun 18, 2010 at 11:21:52AM +0200, Jan Ingvoldstad wrote: > > : On Fri, Jun 18, 2010 at 11:15, Smylers 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. I was only thinking about that specific warning, not generally warnings that might be of use to Perl 5 programmers. And I don't see how warning about calling reverse on a scalar would be awful. It isn't something that makes sense to do (it's a no-op), and it isn't just former Perl 5 programmers who might make that mistake; anybody who does could be warned about it. > 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. Yeah, for this specific case my request is a warning by default. Smylers -- http://twitter.com/Smylers2
Re: Two questions on Perl 6 functionality
Hi, Xi Yang wrote: > 1: Does Perl 6 has method modifiers like those in Moose? Perl 6 has traits, so you can write for example class A { method x() is rw { ...} } to indicate that it's an lvalue routine (though I don't think it's implemented in Rakudo yet). > Where can I get the doc about that? By reading apocalypse? The Apocalypses are of historical interest only. Please read the Synopsis instead http://perlcabal.org/syn/ http://perlcabal.org/syn/S06.html http://perlcabal.org/syn/S12.html > 2: Does Perl 6 has build-in support for message passing (like those in Glib > and Actionscript)? I fear I'm not qualified to answer that, and I hope somebody else picks up the topic. Cheers, Moritz