Open toddr opened 4 years ago
I'm in two minds about this one. It'd be great to have "default-sensible" semantics but as ever that really strong noise of "back-compat" comes to mind. I wonder if there's a hybrid ground somewhere.
Here's a Bold and Couragous[1] idea: What if we invented a new file suffix - for sake of argument lets call it .p5
, which basically acts like a .pm
module but with automatically some fixed pragmata in effect - use strict; use warnings; use feature :5.30
or somesuch. Setting aside the small matter of how to handle conflicts if both .pm
and .p5
exist, that might give a nice way to start writing default-nice code.
A tiny problem comes with actual scripts (i.e. non-modules but instead files beginning with a #!perl
shebang), but maybe that can be solved by the addition of some lettered flag. Picking totally at random the fact that my perlrun(1)
does not mention a -y
flag, maybe solved by
#!/usr/bin/perl -y
to default the same set of pragmata.
[1] - I slightly refer to the Yes Minister sense, which for those not familiar with it can be explained by the third quote in https://en.wikiquote.org/wiki/Yes,_Minister#Episode_Six:_The_Right_to_Know
nice idea @leonerd to use a custom file suffix to imply, give me all the power, I like it
@atoomic I wouldn't say "all" - "all" would basically imply doing
use feature ':latest';
and that comes with it the inherent danger that the moment you update perl you get a new feature set of new features, new keywords, any of which might now conflict. This is why i called it Bold and Courageous.
Really I don't see what's wrong with
use feature ':5.30';
or whatever your target is for this file. It keeps every individual file safe from accidental breakage from any future version of perl.
I could see use feature ':5.30';
or whatever doing whatever is considered the sane boilerplate at that version.
If we add no legacy 'indirect'
for 5.32, then use feature ':5.32';
might also enable that without breaking older code.
Isn't there a CPAN module that already does this? With the versioning?
The problem with a new suffix is your typical perl program running on a POSIX-ish system doesn't have a suffix, it's just called "ack", or "rename"
@tonycoz for programs invoked via shebang (i.e. the ack
-like usecase), a new flag could handle that - see my -y
example.
Though I should again clarify - I don't actually advocate for that position. I'd much rather we just did use 5.032
or use feature ':5.32';
or whatever
use strict, use warnings, etc. defaulted to on.
Code which can't support it must do
no strict