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

[perl #97978] defined *{"foo"} is false for some magical vars

Thread Previous
Father Chrysostomos
August 28, 2011 18:07
[perl #97978] defined *{"foo"} is false for some magical vars
Message ID:
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #97978]
# in the subject line of all future correspondence about this issue. 
# <URL: >

defined *{"foo"} does not normally autovivify a glob. But it *does* autovivify it if it is a glob for a built-in variable created on the fly. perl likes to pretend that those have always existed. The list of these is in is_gv_magical_sv in gv.c.

But, over time, new variables have been added (in gv_fetchpvn_flags) without corresponding entries in is_gv_magical_sv. ${^UTF8CACHE} is one such variable.

While I could just go in and add them, that will not eliminate the cause of the problem: unmaintainability.

Would it be feasible to merge the switch blocks in the two functions? My first thought is to put them in a static function with a flag to indicate whether the entry should be autovivified. That would be a lot of if()s, which would be almost as unmaintainable. But that makes me wonder whether is_gv_magical_sv couldn’t just call gv_fetchpvn_flags itself, since each time it returns true the glob gets autovivified anyway.

Site configuration information for perl 5.15.2:

Configured by sprout at Wed Aug 24 09:37:32 PDT 2011.

Summary of my perl5 (revision 5 version 15 subversion 2) configuration:
  Derived from: cc04abeff265a4870dc77e0ba94306a557039beb
  Ancestor: 7bc95ae1a56bd0ccfe9db1092344cd2d1566beca
    osname=darwin, osvers=10.5.0, archname=darwin-thread-multi-2level
    uname='darwin pint.local 10.5.0 darwin kernel version 10.5.0: fri nov 5 23:20:39 pdt 2010; root:xnu-1504.9.17~1release_i386 i386 '
    config_args='-de -Dusedevel -DDEBUGGING -Duseithreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O3 -g',
    cppflags='-fno-common -DPERL_DARWIN -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.15.2:

Environment for perl 5.15.2:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About