Hacker News new | past | comments | ask | show | jobs | submit login

In Perl 5, for and foreach have been aliases for eachover for a very, very long time.

    # perl -E 'foreach (my $i=0; $i<3; $i++) { say $i }'
    0
    1
    2
    # perl -E 'for my $i (0..2) { say $i }'
    0
    1
    2
I never use foreach in Perl 5, and that's what I'm paid to write in. This is just a reaffirming that "for" is the preferred syntax (and this isn't a TMTOWTDI thing, this is two reserved words for the exact same code construct thing).

Moose, interestingly enough, is based on backporting the then-proposed Perl 6 object system, so a lot of the concept sand terminology will be the same.

But it sounds like you are talking about transitioning from Perl 5 to Perl 6. Why? The naming is confusing, but most people are not expected to convert codebases to Perl 6. It's not an upgrade, it an also. If you want both, use Inline::Perl5[1] and just call back and forth between the interpreters.

1: https://github.com/niner/Inline-Perl5




Though to be fair, for the last year or so, every time I've needed to hack on a p5 script for $work, my first step has been to convert it to p6. It usually is pretty quick for 50-100 line scripts, and generally it's a lot easier to reason about changing the code once it's in p6.


With apologies for the blizzard of questions:

Do you have/write test suites? In P5? P6?

Have you seriously tried any of the p5-to-p6 translators with your scripts?

Was the usage message typically much-improved, about-the-same, or needs-work after your first successful compile?

Same question for command line argument binding?

Any speed stories? Scripts that started unacceptably slow but eventually got there? Ones that beat their Perl 5 originals? Ones that didn't really make it yet?

Have you converted any of your Perl 6 conversions back in to Perl 5 code (to retain the clarity developed in the conversion to 6 but regain the speed that Perl 5 has)?

Do any of your conversions use Perl 5 modules?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: