develooper Front page | perl.perl5.porters | Postings from November 2011

Re: what's "use VERSION" all about?

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
November 29, 2011 07:31
Subject:
Re: what's "use VERSION" all about?
Message ID:
20111129153054.GC11678@cancer.codesimply.com
* Nicholas Clark <nick@ccl4.org> [2011-11-29T09:21:50]
> So, when I write the code, I know I'm only using three particular features
> from the set that ":v5.18" offers. If I simply use v5.18; there's a risk in
> future that my code will get warnings (if not fatal errors) of "I'm sorry,
> we can't do v5.18; any more".
> 
> So I write my code more defensively (and arguably maintainability). I only
> import the features I need. `use feature qw(foo bar baz);`
> 
> All is good. I won't get errors when experimental features "clunk" and "sock",
> also part of ":v5.18" are removed. My code keeps working.
> 
> However, I'm now using an explicit list of "things that I want". Which means
> the "make it work by retroactively adding status quo features to the list"
> idea doesn't work for me. The feature "inc_operator" wasn't *in* the :v5.18
> list when I enumerated the bits I wanted.

You start with the default group.  If you import those three features, the
default group is still there, and includes inc_operator.

As I said to David Golden, I think this points to only clearing the feature set
when asking for a whole version group.  Otherwise, you're adding to the
default.  Another way to do this (and possibly better, I'm not deeply thinking,
just typing as I think) is to say that when you say "use VERSION" it doesn't
say: feature->unimport; feature->import(':VERSION');

It says:  feature->reset_to_default; feature->import(':VERSION') and the
version group is responsible for saying which default features to disable.

-- 
rjbs

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About