No, a list in scalar context returns its last element. It has to, that's how the 'scalar comma operator' works. What seems weird here is that the scalar context propagates down to the arrays, because we expect arrays to interpolate into lists, but in fact that only happens (and only can happen) when the list is in list context.
I think what we forget here is that an array is not the same as a list; it's an expression which has to be evaluated, and it doesn't return the same thing in scalar context as the equivalent list. The result is exactly the same as this code, which is much less surprising:
sub ar1 { wantarray ? qw/foo bar/ : 2 } sub ar2 { wantarray ? qw/a b c d/ : 4 } print scalar (ar1(), ar2());]]>
The Camel Book mentions "This is just like C's comma operator."
I have not thought about it enough, but the current behaviour does not seem intuitive, and therefore seems to violate the famous principle of least astonishment (for me). Ha! :-)
But as chris says, it is probably my duty not to be astonished.. ;-)
]]>20:16 mohawk TimToady: if perl5 were to be re-branded as Camel Perl (subject of course to a conversation with Mr O'Reilly), how would you feel about that? 20:16 * TimToady thinks it wouldn't make any substantive difference 20:17 mohawk are you "no strong feelings one way or the other"? 20:17 * TimToady thinks people will still call it perl5 20:17 * TimToady has no strong feelings on the branding of perl5 these days]]>
I only yesterday figured out how to run tests on Perl6 so once I have some rational bugs to report I will give them. I just hate to go on IRC and say "It doesn't work." However now I can see its something to do with subroutine attributes. Most of my applications use Catalyst, which makes heavy use of sub attributes, but I guess that isn't straightforwardly translated to Perl6. Looks like Perl6 has a version of Attributes but they do something totally different. Catalyst uses attributes as tagged metadata on a subroutine, seems like Perl6 version of this is more like decorators. maybe we could do something like 'sub action is_metadata(CATALYST_ATTRS) { ... } in translation. But I think that would need to get hacked into Inlin::Perl5 and I am nowhere near that level.
]]>Looks like I forget to hit send or something, I had a longer response but the short version is I don't know enough to give a rational but report, but I think it has something to do with Catalyst subroutine attributes and how Perl6 attributes are totally different. When I figure out more I will definitely say something because web applications that want async would be a great reason to port stuff from Perl5 to Perl6 but if I can't make an existing Catalyst application run thats a totally no go. Thanks for the reply -jnap
]]>My idea is
package Foo is class {
}
or
package Foo : class {
}
How about this?
We're trying very hard to avoid overloading the meaning of existing Perl features, so we deliberately didn't go with the word package
. The package
keyword simply declares something as being in a given namespace. The class
keyword in Corinna does the same thing, but it's a historical accident in Perl that classes and packages are sort of the same thing.
In reality, a class
is a data type, not a namespace. They're fundamentally different. While I don't know if it can be fixed, in the long-term, I would love to see the two ideas fully separated in Perl.
Best,
Ovid
https://en.wikipedia.org/wiki/Argument_from_authority
If these people have genuine authority gained from years of hard experience in this field then they will be able to tell us in a few cogent words why Corinna is so much better than Moose and all the other OO systems available on CPAN. They will be able to tell us the mathematical theorems that underlie their work. They will be convincing. But a bald appeal to authority, is not only not convincing, it is also demeaning because it divides Perl people in to two classes, the "hoi poloi" whose thoughts on OO are not thought worth considering and a small remainder whose thoughts, apparently are so valuable that they do not even have to back up their ideas with indefeasible argumentation.
Please could you rewrite the start of this article so that we all know the compelling reasons why Corinna is so good: then the issues can be weighed on their merits genuine or otherwise rather relying on the mere assumption of authority.
]]>Of course, that is not an exhaustive list of all the benefits of the Corinna proposal, but I felt it was enough for a single article.
As for arguing from authority at the start of the article, I don't believe that's what I'm doing. Sure, I do mention that the project is a collaboration by a large number of people who are acknowledged experts in OO Perl, but I specifically say that I mention those contributors merely to reassure the reader, not as an argument in favour of Corinna.
After all, why would I expect the reader to even consider my subsequent arguments for this project, without first establishing that the proposal is likely to be worth their time and effort? Specifically, that it is not some random crazy idea, but has been designed by a group of people with a proven track record in the field.
Yes, arguing from authority is unquestionably fallacious. And, yes, if I had written (or even implied): "This proposal should be adopted because X, Y, and Z worked on it", then that would certainly be an invalid argument.
But simply pointing out that this project has the participation and support of a large number of experts is not the same as arguing for it from authority.
Rather, it's a way of quickly establishing that the project is a serious one, with a wide variety of experienced and credible contributors...before I launch into providing half a dozen actual reasons why it's worth your time to consider. And then conclude by explicitly urging you (and all my readers) to apply the only truly compelling assessment available to you: to investigate it yourself.
]]>