Perl 7 Thoughts
Overall, I think the Perl 7 announcement is great news.
I only have one small objection:
One of the proposed changes is to remove
Perl 4-style prototype definitions (use
:prototype()
instead)
My objection to this is that :prototype
was only introduced in Perl 5.20. Code using it won't work as expected on older versions of Perl.
The wording of this proposed change mischaracterizes the older sub prototype syntax as something Perl-4-specific, whereas the reality is that up until Perl 5.20, it was the way to declare prototypes.
This means that if I want my code to support Perl 7, I need to abandon Perl 5.18 and below, or jump through some fairly ugly hoops.
I don't like that.
It's a bit worse than that. Since v5.30 (and v5.26, but not v5.28) mandates the escape of the left brace in a pattern, your v5.32/v7 code has to comply with that.
I recently updated my Object::Iterate module to use
:prototype
. I'm likewise sad about bumping the requirement up to 5.20, but there's black magic eval stuff I could do to support 5.008. I don't know if I like that those.And thanks for the correction on prototypes. Those were never a Perl 4 thing. Total lapse on my part. No one told me to say that and I completely made it up. We're correcting the announcement.
I haven't tested it, but a "solution" could be to define the subs with no prototypes at all, then use
set_prototype
from Scalar::Util. That's probably a bit nicer thaneval
.I'd rather not jump through hoops though.
Worse yet, the `set_prototype` has to happen in a `BEGIN` block to take full effect :-/
Well, if it's a module and you're just exporting the subs and not using them internally, then it shouldn't need to be in
BEGIN
, because from your caller's perspective, your whole module is running at compile time.