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

can change the value of 4 #13209

Closed
p5pRT opened this issue Aug 28, 2013 · 4 comments
Closed

can change the value of 4 #13209

p5pRT opened this issue Aug 28, 2013 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 28, 2013

Migrated from rt.perl.org#119501 (status was 'resolved')

Searchable as RT119501$

@p5pRT
Copy link
Author

p5pRT commented Aug 28, 2013

From zefram@fysh.org

Created by zefram@fysh.org

$ perl5.19.3 -lwe 'for(1..3) { my $x = \(3+1); print $$x; $$x = 5; }'
4
5
5

I'd expect that the sequence "my $x = \(3+1); print $$x;" would always
print 4. Whether assignment to $$x is then permitted is up for debate,
but such assignment mustn't break the behaviour of the next execution
of that 4-printing code.

Perl 5.19.2 and earlier do not permit the assignment ("Modification of
a read-only value attempted"). Because it's immutable, it's acceptable
for \(3+1) to reference the same 4 each time. 5.19.3 is also referencing
the same scalar each time, but now it's a variable, so referencing the
same one each time is semantically significant.

Interestingly, if "\(3+1)" is replaced with "\4" then 5.19.3 prohibits
the assignment, just as earlier Perls do. Also, if it's replaced with
"\(3+$z)", with $z initialised to 1, both 5.19.3 and earlier Perls permit
the assignment and print 4 each time, indicating that they're generating
a fresh variable each time.

I think FC was aiming to resolve the inconsistency of what the addition
operator returns. He seems to have aimed for a literal expression to
consistently return an immutable scalar while an arithmetic expression
consistently returns a mutable scalar. The bit that's missing is that
it needs to consistently be a *fresh* mutable scalar.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.19.3:

Configured by root at Wed Aug 21 10:26:55 UTC 2013.

Summary of my perl5 (revision 5 version 19 subversion 3) configuration:
   
  Platform:
    osname=linux, osvers=2.6.32-5-686, archname=i686-linux-64int-ld
    uname='linux beryllium.photobox.priv 2.6.32-5-686 #1 smp mon feb 25 01:04:36 utc 2013 i686 gnulinux '
    config_args='-des -Dusedevel -Uversiononly -Duseshrplib -Duse64bitint -Duselongdouble -Uusethreads -Uusemultiplicity -Dprefix=/opt/perl-5.19.3 -Dsiteprefix=/opt/perl-5.19.3 -Dvendorprefix=/opt/perl-5.19.3/vendor -Doptimize=-ggdb -O2 -Dcccdlflags=-fPIC -O2 -pipe'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-ggdb -O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.7.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/i386-linux-gnu /lib/../lib /usr/lib/i386-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/perl-5.19.3/lib/5.19.3/i686-linux-64int-ld/CORE'
    cccdlflags='-fPIC -O2 -pipe', lddlflags='-shared -ggdb -O2 -L/usr/local/lib -fstack-protector'



@INC for perl 5.19.3:
    /opt/perl-5.19.3/lib/site_perl/5.19.3/i686-linux-64int-ld
    /opt/perl-5.19.3/lib/site_perl/5.19.3
    /opt/perl-5.19.3/vendor/lib/vendor_perl/5.19.3/i686-linux-64int-ld
    /opt/perl-5.19.3/vendor/lib/vendor_perl/5.19.3
    /opt/perl-5.19.3/lib/5.19.3/i686-linux-64int-ld
    /opt/perl-5.19.3/lib/5.19.3
    .


Environment for perl 5.19.3:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/opt/perl-5.19.3/bin:/root/pub/i686-pc-linux-gnu/bin:/root/pub/common/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/games:/opt/geoip/bin:/opt/httpd/bin:/opt/perl/bin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Sep 17, 2013

From @cpansprout

Fixed in acb3405. BTW, have you seen Acme​::constant? :-)

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Sep 17, 2013

From [Unknown Contact. See original ticket]

Fixed in acb3405. BTW, have you seen Acme​::constant? :-)

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Sep 17, 2013

@cpansprout - Status changed from 'new' to 'resolved'

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