Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use feature ':all' #17029

Closed
p5pRT opened this issue May 31, 2019 · 5 comments
Closed

use feature ':all' #17029

p5pRT opened this issue May 31, 2019 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented May 31, 2019

Migrated from rt.perl.org#134156 (status was 'open')

Searchable as RT134156$

@p5pRT
Copy link
Author

p5pRT commented May 31, 2019

From @djerius

Created by @djerius

As of Perl v5.16, the feature pragma has provided an import tag of :all.

The documentation describes its use only in the negative, e.g. when explaining
how

  use v5.10.0;

works via

  no feature '​:all';
  use feature '​:5.10';

Is there a reason that one should not use '​:all' positively? As in

  use feature '​:all';

Today a Perl beginner posted on stackoverflow [1] about the
mysterious errors they were getting when they removed the 'use 5.30'
from their program. Many of the responses revolved around what a
feature was, and how to enable particular features, and which version a
feature was found in.

While the beginner's dilemma opened up a pedagogical opportunity, it
struck me that it also dramatically increased the cognitive load for a
newcomer, as it forces them to delve into the minutiae of features.

There's a handy CPAN module, 'latest', which gives the program access
to the latest features available on the running Perl. The '​:all' tag
accomplishes the same thing, with the benefit that it is a standard
part of the more recent modern Perls.

If there are no objections to using '​:all' to import symbols, it would
make sense to indicate that in the documentation; one could simply
then suggest to the beginner to

  use feature '​:all';

to get their code working, and point them at the feature pragma for
future exploration.

Thanks as always for your efforts!

Diab

[1] https://stackoverflow.com/questions/56399608/helloworld-example-for-perl-gives-two-errors-when-not-specifying-use-5-30-0

Perl Info

Flags:
    category=library
    severity=wishlist
    module=feature

Site configuration information for perl 5.28.1:

Configured by dj at Mon Dec 17 10:30:49 EST 2018.

Summary of my perl5 (revision 5 version 28 subversion 1) configuration:
   
  Platform:
    osname=linux
    osvers=4.9.0-8-amd64
    archname=x86_64-linux_debian-9-thread-multi
    uname='linux macabre 4.9.0-8-amd64 #1 smp debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 gnulinux '
    config_args='-de -Dprefix=/proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9 -Uinstallusrbinperl -Dperladmin=none -Dlocincpth=/proj/axaf/ots/include -Darchname=x86_64-linux_debian-9 -Dusethreads -Dotherlibdirs=/proj/axaf/simul/lib/perl5:/proj/axaf/simul/x86_64-linux_debian-9/lib/perl5 -Dloclibpth=/proj/axaf/ots/x86_64-linux_debian-9/lib -Dglibpth=/lib /usr/lib -Dldflags=-L/proj/axaf/ots/x86_64-linux_debian-9/lib -Wl,-rpath=/proj/axaf/ots/x86_64-linux_debian-9/lib -Duseshrplib'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/proj/axaf/ots/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/proj/axaf/ots/include'
    ccversion=''
    gccversion='6.3.0 20170516'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags ='-L/proj/axaf/ots/x86_64-linux_debian-9/lib -Wl,-rpath=/proj/axaf/ots/x86_64-linux_debian-9/lib -fstack-protector-strong'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /proj/axaf/ots/x86_64-linux_debian-9/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.24.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.24'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/5.28.1/x86_64-linux_debian-9-thread-multi/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/proj/axaf/ots/x86_64-linux_debian-9/lib -fstack-protector-strong'



@INC for perl 5.28.1:
    /proj/axaf/simul/lib/perl5/x86_64-linux_debian-9-thread-multi
    /proj/axaf/simul/lib/perl5
    /home/dj/research/lib/perl5
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/site_perl/5.28.1/x86_64-linux_debian-9-thread-multi
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/site_perl/5.28.1
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/5.28.1/x86_64-linux_debian-9-thread-multi
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/5.28.1
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/site_perl/5.28.0/x86_64-linux_debian-9-thread-multi
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/site_perl/5.28.0
    /proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/lib/site_perl
    /proj/axaf/simul/lib/perl5/x86_64-linux_debian-9-thread-multi
    /proj/axaf/simul/lib/perl5
    /proj/axaf/simul/x86_64-linux_debian-9/lib/perl5


Environment for perl 5.28.1:
    HOME=/home/dj
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/soft/SYBASE15.7/DataAccess64/ODBC/lib:/soft/SYBASE15.7/DataAccess/ODBC/lib:/soft/SYBASE15.7/OCS-15_0/lib:/soft/SYBASE15.7/OCS-15_0/lib3p64:/soft/SYBASE15.7/OCS-15_0/lib3p:
    LOGDIR (unset)
    PATH=/home/dj/.plenv/libexec:/home/dj/.plenv/plugins/link-axaf/bin:/home/dj/.plenv/plugins/perl-build/bin:/home/dj/.plenv/plugins/plenv-contrib/bin:/soft/SYBASE15.7/OCS-15_0/bin:/home/dj/.rbenv/shims:/home/dj/.rbenv/bin:/home/dj/.pyenv/plugins/pyenv-virtualenv/shims:/home/dj/.pyenv/shims:/home/dj/.pyenv/bin:/home/dj/.plenv/shims:/home/dj/.plenv/bin:/home/dj/root/bin:/home/dj/root/bin/hosts:/home/dj/research/bin:/proj/axaf/ots/pkgs/perl-5.28/x86_64-linux_debian-9/bin:/proj/axaf/bin:/proj/axaf/simul/bin:/proj/axaf/simul/x86_64-linux_debian-9/bin:/proj/axaf/ots/x86_64-linux_debian-9/bin:/proj/axaf/ots/bin:/usr/local/bin:/usr/sbin:/bin:/usr/bin:/soft/saord/bin
    PERL5LIB=/proj/axaf/simul/lib/perl5:/home/dj/research/lib/perl5
    PERL_BADLANG (unset)
    PERL_CPANM_HOME=/tmp/dj/cpanm
    PERL_CPANM_OPT=--cascade --mirror /proj/axaf/simul/export/darkpan --mirror https://cpan.org
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2019

From @iabyn

On Fri, May 31, 2019 at 11​:55​:15AM -0700, Diab Jerius (via RT) wrote​:

The documentation describes its use only in the negative, e.g. when explaining
how

use v5.10.0;

works via

no feature '​:all';
use feature '​:5.10';

Is there a reason that one should not use '​:all' positively? As in

use feature '​:all';

It defeats the whole purpose of feature.pm - which is to allow us to
add new features to perl which are not backwards compatible.

If people start adding "use feature '​:all'" to their programs, then their
programs may break on future releases of perl. If lots of people start
adding it, then we'll be told that we can't add a new feature to perl
because it would break too many existing modules that people reply on. So
we'd have to introduce "reluctant" features which aren't enabled by
'​:all'; then we'd have to add '​:really_all', then that would be abused,
and so the cycle continues.

--
The Enterprise is involved in a bizarre time-warp experience which is in
some way unconnected with the Late 20th Century.
  -- Things That Never Happen in "Star Trek" #14

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2019

From @djerius

On Mon, Jun 3, 2019 at 4​:52 AM Dave Mitchell via RT
<perlbug-followup@​perl.org> wrote​:

On Fri, May 31, 2019 at 11​:55​:15AM -0700, Diab Jerius (via RT) wrote​:

The documentation describes its use only in the negative, e.g. when explaining
how

use v5.10.0;

works via

no feature '​:all';
use feature '​:5.10';

Is there a reason that one should not use '​:all' positively? As in

use feature '​:all';

It defeats the whole purpose of feature.pm - which is to allow us to
add new features to perl which are not backwards compatible.

If people start adding "use feature '​:all'" to their programs, then their
programs may break on future releases of perl. If lots of people start
adding it, then we'll be told that we can't add a new feature to perl
because it would break too many existing modules that people reply on. So
we'd have to introduce "reluctant" features which aren't enabled by
'​:all'; then we'd have to add '​:really_all', then that would be abused,
and so the cycle continues.

Thanks. I didn't appreciate that perspective.

While the documentation doesn't explicitly indicate that '​:all' may be
used on import, it is relatively uncommon to come across an export tag
that shouldn't be used on import, so for those who don't grasp the
intricacies of its use (i.e., apparently me) it creates a bit of a
grey area.

Perhaps it might help to put in an explicit statement indicating that
'​:all' should never be used to turn features on, and additionally, to
have import() complain if it is used in that context?

Diab

@tonycoz
Copy link
Contributor

tonycoz commented Oct 18, 2023

I mis-typed the GH ref in the fix, this was fixed by fc5e067

@tonycoz tonycoz closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants