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

Deprecate barewords? #15061

Closed
p5pRT opened this issue Nov 23, 2015 · 31 comments
Closed

Deprecate barewords? #15061

p5pRT opened this issue Nov 23, 2015 · 31 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 23, 2015

Migrated from rt.perl.org#126715 (status was 'rejected')

Searchable as RT126715$

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

Created by @epa

Does anybody use barewords? I know that not everyone runs with 'use
strict' all the time, but is the ancient rule treating an unknown,
unquoted word as a string still useful? Even for the most throwaway
oneliner it seems to get in the way more than it helps. Other
opinions welcome, though.

If there is a consensus that barewords are no longer useful, perhaps
they could start to trigger a deprecation warning? Then in a future
release "use strict 'subs'" or something like it could be built in.

Perl Info

Flags:
    category=core
    severity=wishlist

Site configuration information for perl 5.20.3:

Configured by Red Hat, Inc. at Thu Sep 24 08:45:26 UTC 2015.

Summary of my perl5 (revision 5 version 20 subversion 3) configuration:
   
  Platform:
    osname=linux, osvers=4.1.6-100.fc21.x86_64, archname=x86_64-linux-thread-multi
    uname='linux buildvm-04.phx2.fedoraproject.org 4.1.6-100.fc21.x86_64 #1 smp mon aug 17 22:20:37 utc 2015 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -Dccdlflags=-Wl,--enable-new-dtags -Dlddlflags=-shared -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -Wl,-z,relro  -Dshrpdir=/usr/lib64 -DDEBUGGING=-g -Dversion=5.20.3 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl5 -Dsitearch=/usr/local/lib64/perl5 -Dprivlib=/usr/share/perl5 -Dvendorlib=/usr/share/perl5/vendor_perl -Darchlib=/usr/lib64/perl5 -Dvendorarch=/usr/lib64/perl5/vendor_perl -Darchname=x86_64-linux-thread-multi -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Duseshrplib -Dusethreads -Duseithreads -Dusedtrace=/usr/bin/dtrace -Duselargefiles -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dscriptdir=/usr/bin -Dusesitecustomize'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='5.1.1 20150618 (Red Hat 5.1.1-4)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib64 /lib64 /usr/lib64 /usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
    libs=-lpthread -lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lresolv -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.21.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.21'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,--enable-new-dtags'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-z,relro  -L/usr/local/lib'

Locally applied patches:
    Fedora Patch1: Removes date check, Fedora/RHEL specific
    Fedora Patch3: support for libdir64
    Fedora Patch4: use libresolv instead of libbind
    Fedora Patch5: USE_MM_LD_RUN_PATH
    Fedora Patch6: Skip hostname tests, due to builders not being network capable
    Fedora Patch7: Dont run one io test due to random builder failures
    Fedora Patch15: Define SONAME for libperl.so
    Fedora Patch16: Install libperl.so to -Dshrpdir value
    Fedora Patch22: Document Math::BigInt::CalcEmu requires Math::BigInt (CPAN RT#85015)
    Fedora Patch25: Use stronger algorithm needed for FIPS in t/op/crypt.t (RT#121591)
    Fedora Patch26: Make *DBM_File desctructors thread-safe (RT#61912)
    Fedora Patch27: Report inaccesible file on failed require (RT#123270)
    Fedora Patch28: Use stronger algorithm needed for FIPS in t/op/taint.t (RT#123338)
    Fedora Patch29: Fix debugger y command scope level
    Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux
    Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux


@INC for perl 5.20.3:
    /home/eda/share/perl5
    /home/eda/lib/perl5/
    /home/eda/lib64/perl5/
    /usr/local/lib64/perl5
    /usr/local/share/perl5
    /usr/lib64/perl5/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib64/perl5
    /usr/share/perl5
    .


Environment for perl 5.20.3:
    HOME=/home/eda
    LANG=en_GB.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=C
    LC_CTYPE=en_GB.UTF-8
    LC_MESSAGES=en_GB.UTF-8
    LC_MONETARY=en_GB.UTF-8
    LC_NUMERIC=en_GB.UTF-8
    LC_TIME=en_GB.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/eda/bin:/home/eda/bin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/sbin:/usr/sbin
    PERL5LIB=/home/eda/share/perl5:/home/eda/lib/perl5/:/home/eda/lib64/perl5/
    PERL_BADLANG (unset)
    SHELL=/bin/bash

This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. Wadhwani Asset Management LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 40 Berkeley Square, 3rd Floor, London, W1J 5AL. It is authorised and regulated by the Financial Conduct Authority.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 06​:04​:05AM -0800, Ed Avis wrote​:

# New Ticket Created by "Ed Avis"
# Please include the string​: [perl #126715]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=126715 >

This is a bug report for perl from eda@​waniasset.com,
generated with the help of perlbug 1.40 running under perl 5.20.3.

-----------------------------------------------------------------
[Please describe your issue here]

Does anybody use barewords? I know that not everyone runs with 'use
strict' all the time, but is the ancient rule treating an unknown,
unquoted word as a string still useful? Even for the most throwaway
oneliner it seems to get in the way more than it helps. Other
opinions welcome, though.

If there is a consensus that barewords are no longer useful, perhaps
they could start to trigger a deprecation warning? Then in a future
release "use strict 'subs'" or something like it could be built in.

[Please do not change anything below this line]
-----------------------------------------------------------------

I use

  print STDERR "bla bla";

quite often.

But if you're referring to unquoted strings, they already trigger
a warning​:

  $ perl -wE 'say STDERR 1 ? yes : nope'
  Unquoted string "yes" may clash with future reserved word at -e line 1.
  Unquoted string "nope" may clash with future reserved word at -e line 1.
  yes
  $

If you opt to run it without warnings, it won't warn, and just DWIM.

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

Yes, by 'barewords' I meant to say the treatment of unquoted identifiers as strings, in cases where "use strict 'subs'" would give an error. That is not the case for STDERR.

Barewords will give a warning "clash with future reserved word", but not if they have characters outside [a-z].

My question is first, whether anyone is still using this feature (I have never come across code that uses it outside of golfing and poetry, but I accept that different programmers have different styles), and if the answer to the first question is "no", whether it might be time to officially deprecate this feature.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @ap

* Ed Avis <perlbug-followup@​perl.org> [2015-11-23 15​:05]​:

perhaps they could start to trigger a deprecation warning?

As often disagree as I with you – this might actually be reasonable.

I can’t remember seeing them used on purpose (outside of poetry, as you
mentioned) and have never done so myself.

This seems a useful way to reduce the fraction of /dev/urandom output
that constitutes valid Perl.

Of course this would first go on a branch and get a full CPAN smoke etc
etc. I have no idea if it’s actually feasible in practice to deprecate
unquoted bareword strings. But I would be very curious to at least see
what happens if we pull on that string. After that, we could see.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 06​:53​:30AM -0800, Ed Avis via RT wrote​:

Yes, by 'barewords' I meant to say the treatment of unquoted identifiers as strings, in cases where "use strict 'subs'" would give an error. That is not the case for STDERR.

Barewords will give a warning "clash with future reserved word", but not if they have characters outside [a-z].

My question is first, whether anyone is still using this feature (I have never come across code that uses it outside of golfing and poetry, but I accept that different programmers have different styles), and if the answer to the first question is "no", whether it might be time to officially deprecate this feature.

Are you going to ask the people who aren't reading p5p this as well, or
do you think p5p is representative for the Perl programmers at large?
(I don't think they are).

What is the gain by making this a mandatory warning? If noone is using
it, adding a warning doesn't do much. If people are, what good does it them?

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From Eirik-Berg.Hanssen@allverden.no

On Mon, Nov 23, 2015 at 4​:47 PM, Abigail <abigail@​abigail.be> wrote​:

What is the gain by making this a mandatory warning? If noone is using
it, adding a warning doesn't do much. If people are, what good does it
them?

  It helps people who are not intentionally using this (mis-)feature, but
happen by accident to write code typically one-liners) that uses it (and do
not explicitly enable strictures nor warnings – typically in one-liners, I
guess).

  Like, forgetting to import a constant, or misspelling its name …

Eirik

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 05​:40​:41PM +0100, Eirik Berg Hanssen wrote​:

On Mon, Nov 23, 2015 at 4​:47 PM, Abigail <abigail@​abigail.be> wrote​:

What is the gain by making this a mandatory warning? If noone is using
it, adding a warning doesn't do much. If people are, what good does it
them?

It helps people who are not intentionally using this (mis-)feature, but
happen by accident to write code typically one-liners) that uses it (and do
not explicitly enable strictures nor warnings – typically in one-liners, I
guess).

Like, forgetting to import a constant, or misspelling its name …

Forcing warnings upon users who have choosen not to enable warnings
doesn't sound to me as even remotely user friendly.

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

What is the gain by making this a mandatory warning? If noone is using
it, adding a warning doesn't do much. If people are, what good does it
them?

This is why I ask for views on whether this is still used and still useful.

If people are still using barewords, then I withdraw the proposal. I have no wish to force warnings upon people who use barewords and have chosen not to see the warnings.

If nobody is using it, it seems like a useful simplification (both in language spec and in implementation) to remove the dead wood, that is, to remove barewords from the language. To do so would require the usual deprecation cycle.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From Eirik-Berg.Hanssen@allverden.no

On Mon, Nov 23, 2015 at 5​:43 PM, Abigail <abigail@​abigail.be> wrote​:

Forcing warnings upon users who have choosen not to enable warnings
doesn't sound to me as even remotely user friendly.

  Not all who have not chosen to enable warnings have chosen not to enable
warnings​:

  If warnings were on by default, and had to be explicitly disabled, I'd
grant you that point.

Eirik

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @ap

* Abigail <abigail@​abigail.be> [2015-11-23 16​:50]​:

What is the gain by making this a mandatory warning?

None. But there may be gain in making it a syntax error.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 05​:56​:04PM +0100, Eirik Berg Hanssen wrote​:

On Mon, Nov 23, 2015 at 5​:43 PM, Abigail <abigail@​abigail.be> wrote​:

Forcing warnings upon users who have choosen not to enable warnings
doesn't sound to me as even remotely user friendly.

Not all who have not chosen to enable warnings have chosen not to enable
warnings​:

If warnings were on by default, and had to be explicitly disabled, I'd
grant you that point.

If everyone who doesn't enable warnings didn't chose to do so, you may
have a point.

Taken away *choice* from *everyone* just so someone somewhere may have
a benefit doesn't sound me as a even remotely user friendly.

Besides, if that's the argument, why just this warning? Why not make
every warning mandatory?

I'd say issue a deprecation warning once we have a schedule were the
feature is removed, and replaced by something else. Deprecation does
not mean "I don't like the style, so other shall not use it". That's
not what Perl is about.

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From Eirik-Berg.Hanssen@allverden.no

On Mon, Nov 23, 2015 at 6​:55 PM, Abigail <abigail@​abigail.be> wrote​:

If everyone who doesn't enable warnings didn't chose to do so, you may
have a point.

Taken away *choice* from *everyone* just so someone somewhere may have
a benefit doesn't sound me as a even remotely user friendly.

  The choice is not taken away – you just need to make it yourself​:

$ perl -E 'sub foo :locked { }'
Use of :locked is deprecated at -e line 1.
$ perl -E 'no warnings "deprecated"; sub foo :locked { }'
$

Eirik

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

I'd say issue a deprecation warning once we have a schedule were the feature is removed, and replaced by something else.

I think in the case of barewords the replacement feature has been present in Perl for a while...

Instead of

  print hello;

you should, in the new way of doing things, write

  print 'hello';

Deprecation does not mean "I don't like the style, so other shall not use it".

Indeed not. It may however be a case of​: nobody whatsoever uses this style, and so it is not doing any good to keep it (while it does cruft up the language somewhat). Hence this request. To reiterate​: I am *asking* whether anybody uses barewords. If they are still used, then close this bug and keep them.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 10​:00​:59AM -0800, Ed Avis via RT wrote​:

I'd say issue a deprecation warning once we have a schedule were the feature is removed, and replaced by something else.

I think in the case of barewords the replacement feature has been present in Perl for a while...

Instead of

print hello;

you should, in the new way of doing things, write

print 'hello';

Bad example. The first one writes $_ to the handle named hello, the
second one write the string 'hello' to the current default filehandle.

Deprecation does not mean "I don't like the style, so other shall not use it".

Indeed not. It may however be a case of​: nobody whatsoever uses
this style, and so it is not doing any good to keep it (while it does
cruft up the language somewhat). Hence this request. To reiterate​:
I am *asking* whether anybody uses barewords. If they are still used,
then close this bug and keep them.

But you will never know who does, or does not, use this style. And
asking on p5p just reaches the tiniest fraction of Perl programmers --
you may reach more Perl programmers by just asking random people at
a large train station.

And by all means, if you have good reasons why this syntax should be
outlawed, (because there's this awesome new feature you want to implement,
or it speeds up perl significantly, or ...), raise them, and discuss them.

Just issueing a mandatory warning only annoys people, but doesn't
remove the feature.

I'm not opposed removing this feature if there're good reasons. I'm
just not thrilled about a warning for the sake of having a warning.

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

Actually, I would expect p5-porters to be the place most likely to find users of odd language quirks like barewords. Tom Christiansen was perhaps the only Perl programmer still using the 'do SUBROUTINE(LIST)' form, in some presumably ancient scripts. (Note that it ended up being deprecated despite still having at least one active user.) Of course you are right that the readers of the list don't have exhaustive knowledge of all Perl code still in existence, and can't say for sure whether barewords are not still used somewhere, but that is true for every language change.

I am not suggesting to add a warning for the sake of a warning. I am suggesting to remove barewords from the language, if indeed they are completely unused and unwanted by anyone. Naturally, the first step in removing them would be to add a deprecation warning, but that is not the end point.

There are reasons to get rid of barewords, which I would be happy to discuss, but I think a necessary first step is a quick survey to see if any of the p5-porters, at least, are still using them or know of code which still uses them.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @ikegami

On Mon, Nov 23, 2015 at 9​:30 AM, Abigail <abigail@​abigail.be> wrote​:

I use

print STDERR "bla bla";

quite often.

Neither "print" nor "STDERR" are barewords in that program. A bareword is
an identifier treated as a string since it has no other meaning. "print" is
treated as an operator, and "STDERR" as a glob(?).

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @bulk88

On Mon Nov 23 06​:53​:30 2015, ed wrote​:

Yes, by 'barewords' I meant to say the treatment of unquoted
identifiers as strings, in cases where "use strict 'subs'" would give
an error. That is not the case for STDERR.

Barewords will give a warning "clash with future reserved word", but
not if they have characters outside [a-z].

My question is first, whether anyone is still using this feature (I
have never come across code that uses it outside of golfing and
poetry, but I accept that different programmers have different
styles), and if the answer to the first question is "no", whether it
might be time to officially deprecate this feature.

https://metacpan.org/release/BULKDD/Acme-Win32-PEPM-0.02 uses them to pack .pm files. I've attached a sample packed .pm.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @bulk88

Test.pm

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @mauke

Am 23.11.2015 um 20​:49 schrieb bulk88 via RT​:

On Mon Nov 23 06​:53​:30 2015, ed wrote​:

Yes, by 'barewords' I meant to say the treatment of unquoted
identifiers as strings, in cases where "use strict 'subs'" would give
an error. That is not the case for STDERR.

Barewords will give a warning "clash with future reserved word", but
not if they have characters outside [a-z].

My question is first, whether anyone is still using this feature (I
have never come across code that uses it outside of golfing and
poetry, but I accept that different programmers have different
styles), and if the answer to the first question is "no", whether it
might be time to officially deprecate this feature.

https://metacpan.org/release/BULKDD/Acme-Win32-PEPM-0.02 uses them to pack .pm files. I've attached a sample packed .pm.

How much of that magic is fixed bytes? Because if it's just two bytes
('MZ'), you can work around it with 'MZ() if 0;' or similar. No barewords!

--
Lukas Mai <plokinom@​gmail.com>

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @exodist

I can think of one place where people may be accidentally using this, and
that is in import arguments to packages that also turn on 'strict' and
'warnings' for you.

use Foo xxx, yyy, -foo;

If you use strict and warnings before that then it will fail. However if
that turns on strict and warnings like Moose and many other packages these
days then it will work fine, and do what you expect (stringify the
barewords).

I am not making a judgement call on weather people SHOULD or SHOULD NOT do
this. However I have seen it done, and discovered it when I realized I had
accidentally been doing it in a few places.

-Chad

On Mon, Nov 23, 2015 at 11​:57 AM, Lukas Mai <plokinom@​gmail.com> wrote​:

Am 23.11.2015 um 20​:49 schrieb bulk88 via RT​:

On Mon Nov 23 06​:53​:30 2015, ed wrote​:

Yes, by 'barewords' I meant to say the treatment of unquoted
identifiers as strings, in cases where "use strict 'subs'" would give
an error. That is not the case for STDERR.

Barewords will give a warning "clash with future reserved word", but
not if they have characters outside [a-z].

My question is first, whether anyone is still using this feature (I
have never come across code that uses it outside of golfing and
poetry, but I accept that different programmers have different
styles), and if the answer to the first question is "no", whether it
might be time to officially deprecate this feature.

https://metacpan.org/release/BULKDD/Acme-Win32-PEPM-0.02 uses them to
pack .pm files. I've attached a sample packed .pm.

How much of that magic is fixed bytes? Because if it's just two bytes
('MZ'), you can work around it with 'MZ() if 0;' or similar. No barewords!

--
Lukas Mai <plokinom@​gmail.com>

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 01​:43​:05PM -0500, Eric Brine wrote​:

On Mon, Nov 23, 2015 at 9​:30 AM, Abigail <abigail@​abigail.be> wrote​:

I use

print STDERR "bla bla";

quite often.

Neither "print" nor "STDERR" are barewords in that program. A bareword is
an identifier treated as a string since it has no other meaning. "print" is
treated as an operator, and "STDERR" as a glob(?).

The output of "perldoc -f print" contains the following phrase​:

  If you're storing handles in an array or hash, or in general
  whenever you're using any expression more complex than a bareword
  handle or a plain, unsubscripted scalar variable to retrieve it,
  you will have to use a block returning the filehandle value
  instead, in which case the LIST may not be omitted​:

If "STDERR" isn't a bareword, then which bareword is this phrase
referring to?

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @Abigail

On Mon, Nov 23, 2015 at 12​:00​:53PM -0800, Chad Granum wrote​:

I can think of one place where people may be accidentally using this, and
that is in import arguments to packages that also turn on 'strict' and
'warnings' for you.

use Foo xxx, yyy, -foo;

If you use strict and warnings before that then it will fail. However if
that turns on strict and warnings like Moose and many other packages these
days then it will work fine, and do what you expect (stringify the
barewords).

I am not making a judgement call on weather people SHOULD or SHOULD NOT do
this. However I have seen it done, and discovered it when I realized I had
accidentally been doing it in a few places.

Here's another accidental way​:

  $ perl -le '$x = 'foo'; print $x'

Abigail

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @bulk88

On Mon Nov 23 11​:58​:25 2015, plokinom@​gmail.com wrote​:

Am 23.11.2015 um 20​:49 schrieb bulk88 via RT​:

https://metacpan.org/release/BULKDD/Acme-Win32-PEPM-0.02 uses them to
pack .pm files. I've attached a sample packed .pm.

How much of that magic is fixed bytes? Because if it's just two bytes
('MZ'), you can work around it with 'MZ() if 0;' or similar. No
barewords!

Just the first 2 bytes are magic, not the semicolon. Someone a while ago told me to use : and make it an unused label but I've never tried it. To fit "MZ() if 0;", I'd have to shorten the do not edit comment. There are only 2 free bytes (as spaces) before the binary escaping heredoc. The binary escaping heredoc must escape bytes 0x3C/60-0x3F/63 so it can not be moved.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @cpansprout

On Mon Nov 23 10​:00​:59 2015, ed wrote​:

I am
*asking* whether anybody uses barewords.

I, for one, have many legacy programs that use them. I really do not want to have to sift through them and clean them up. If all new programs use strict, then such a removal would not affect any new code anyway, whether positively or negatively.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @epa

Abigail is right​: STDERR is called a 'bareword filehandle'. I should have said 'deprecate barewords-as-strings'.

Although an Acme-namespace module might not be enough by itself to establish a current 'use' of this feature, if F.C. has plenty of code that relies on treating barewords as strings, I guess that vetoes the proposal. I do still think that Perl's grammar has some musty corners that can be cleaned up, of which bareword strings are one example. But I would not push through such a change against existing, working code.

IMHO the warning on 'future reserved word' is a bit useless and could be scrapped, but I will file a separate bug for that.

@p5pRT
Copy link
Author

p5pRT commented Nov 23, 2015

From @ikegami

On Mon, Nov 23, 2015 at 3​:28 PM, Abigail <abigail@​abigail.be> wrote​:

On Mon, Nov 23, 2015 at 01​:43​:05PM -0500, Eric Brine wrote​:

On Mon, Nov 23, 2015 at 9​:30 AM, Abigail <abigail@​abigail.be> wrote​:

I use

print STDERR "bla bla";

quite often.

Neither "print" nor "STDERR" are barewords in that program. A bareword is
an identifier treated as a string since it has no other meaning. "print"
is
treated as an operator, and "STDERR" as a glob(?).

The output of "perldoc -f print" contains the following phrase​:

 If you're storing handles in an array or hash\, or in general
 whenever you're using any expression more complex than a bareword
 handle or a plain\, unsubscripted scalar variable to retrieve it\,
 you will have to use a block returning the filehandle value
 instead\, in which case the LIST may not be omitted&#8203;:

If "STDERR" isn't a bareword, then which bareword is this phrase
referring to?

It's referring to "STDERR", but STDERR is not a bareword there. "A word
that has no other interpretation in the grammar will be treated as if it
were a quoted string. These are known as 'barewords'." Bad doc.

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2015

From @ap

* Eric Brine <ikegami@​adaelis.com> [2015-11-23 22​:45]​:

It's referring to "STDERR", but STDERR is not a bareword there. "A
word that has no other interpretation in the grammar will be treated
as if it were a quoted string. These are known as 'barewords'." Bad
doc.

There is exactly one place in the docs which says that, and literally
every other mention of “bareword” in the docs contradicts it – including
itself.

Bad doc, indeed.

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2015

From @epa

Actually, the phrase 'bareword filehandles' is common usage.
https://www.google.com/search?q=bareword+filehandles

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2015

From @tonycoz

On Mon Nov 23 13​:11​:57 2015, ed wrote​:

Abigail is right​: STDERR is called a 'bareword filehandle'. I should
have said 'deprecate barewords-as-strings'.

Although an Acme-namespace module might not be enough by itself to
establish a current 'use' of this feature, if F.C. has plenty of code
that relies on treating barewords as strings, I guess that vetoes the
proposal. I do still think that Perl's grammar has some musty corners
that can be cleaned up, of which bareword strings are one example.
But I would not push through such a change against existing, working
code.

Ok, closing.

Tony

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 2015

@tonycoz - Status changed from 'open' to 'rejected'

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

1 participant