develooper Front page | perl.perl5.porters | Postings from August 2013

[perl #119239] started out as doc clarification needed in 'eval...but...

Thread Next
From:
Linda Walsh
Date:
August 12, 2013 05:25
Subject:
[perl #119239] started out as doc clarification needed in 'eval...but...
Message ID:
rt-3.6.HEAD-2552-1376285121-85.119239-75-0@perl.org
# New Ticket Created by  Linda Walsh 
# Please include the string:  [perl #119239]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=119239 >



This is a bug report for perl from perl-diddler@tlinx.org,
generated with the help of perlbug 1.39 running under perl 5.16.2.


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


In my copy of the perlfunc man page under the eval keyword...
3rd paragraph, 2nd sentence says:

  In the
  absence of the "unicode_eval" feature, the string will
	sometimes be treated as characters and sometimes as bytes,
	depending on the internal encoding, and source filters
	activated within the "eval" exhibit the erratic, but
	historical, behaviour of affecting some outer file scope that
	is still compiling.

---
The above sentence is as clear as writing as a doctoral computer
scientist might write.

1) Doesn't it, at all, depend on the context of where it is 
called?  I.e. if "use utf8", is in effect, and I say:

----
#!/usr/bin/perl
#use utf8;		#doesn't seem to be necessary for utf8 in source
#	and nothing needs to be done for utf8 on output?
#
my $string="“犬夜叉”";
our $value=int rand 2;
our $newvalue;
our $newvalue2;
use P;
eval q($newvalue="_$string_, val=$value";);
@_ and die @_;
P "value=%s, newvalue=%s, string=%s", $value, $newvalue, $string;
eval qq($newvalue2="_$string\_, val=$value");
@_ and die @_;
P "value=%s, newvalue2=%s, string=%s", $value, $newvalue2, $string;
------------------

ok... so which of my file scope was it supposed to affect and
why doesn't the print have any value for $newvalue or $newvalue2?

doesn't eval use the context from which it is called or is
that only the block eval?

So what does something like:

-----
my $d=int rand 2;
eval q(use Dbg($d,$d,$d));
# (vs.)
eval qq(use Dbg($d,$d,$d));
---
do (or what should it do)?

Does it "do the eval"* at run time
and call "use Dbg(...) at run time, *(including, or not,
based on previous inclusion, but calling 'import', if present,
regardless))

If it did them at run time, shouldn't one of the "newvalue{,}
have a value?

-----

1.B) doc paragraph is unclear and main reason I filed this.
In writing test cases (see what it caused!?), I came across:

1.B.1): Question of why it is outputting UTF8 without
some wide char warning?  Does that mean it reads UTF8 as well?

hmmmm....would that mean the prog could write something it 
couldn't read?

1.B.2)  Does a dynamic eval only work in it's context when it
is not a run-time evaluation (as required by a string), but
is a {block eval}?

So if I have:

{my,our} $d=int rand 2;
eval {use Dbg($d,$d,$d)};

---
wouldn't the block forrm make the useDbg be eval'ed at
compile time? with "$d" being undefined?

($d represents user input in some command line option).

----

Suppose (1) is the main, 1.B is very curious, and I'm
wondering if 1B(1+2) is perl version dependant?...





[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=docs
    severity=medium
---
This perlbug was built using Perl 5.16.2 - Fri Feb 15 01:17:37 UTC 2013
It is being executed now by  Perl 5.16.2 - Fri Feb 15 01:12:05 UTC 2013.

Site configuration information for perl 5.16.2:

Configured by abuild at Fri Feb 15 01:12:05 UTC 2013.

Summary of my perl5 (revision 5 version 16 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=3.4.6-2.10-default, archname=x86_64-linux-thread-multi
    uname='linux build34 3.4.6-2.10-default #1 smp thu jul 26 09:36:26 utc 2012 (641c197) x86_64 x86_64 x86_64 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Dd_dbm_open -Duseshrplib=true -Doptimize=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV -Dotherlibdirs=/usr/lib/perl5/site_perl'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.7.2 20130108 [gcc-4_7-branch revision 195012]', 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='cc', ldflags =' -L/usr/local/lib64 -fstack-protector'
    libpth=/lib64 /usr/lib64 /usr/local/lib64
    libs=-lm -ldl -lcrypt -lpthread
    perllibs=-lm -ldl -lcrypt -lpthread
    libc=/lib64/libc-2.17.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.16.2/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64 -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.16.2:
    /usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.16.2
    /usr/lib/perl5/vendor_perl/5.16.2/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.16.2
    /usr/lib/perl5/5.16.2/x86_64-linux-thread-multi
    /usr/lib/perl5/5.16.2
    /usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.16.2
    /usr/lib/perl5/site_perl
    .

---
Environment for perl 5.16.2:
    HOME=/home/law
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=C
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH=/usr/lib64/mpi/gcc/openmpi/lib64
    LOGDIR (unset)
    PATH=/home/law/bin/lib:/sbin:/usr/local/sbin:/usr/lib64/mpi/gcc/openmpi/bin:/home/law/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.:/usr/lib/qt3/bin:/opt/dell/srvadmin/bin:/usr/sbin:/etc/local/func_lib:/home/law/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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