Skip to content

undef ($a, $b, $c) doesn't work #4685

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

Closed
p5pRT opened this issue Dec 11, 2001 · 5 comments
Closed

undef ($a, $b, $c) doesn't work #4685

p5pRT opened this issue Dec 11, 2001 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 11, 2001

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

Searchable as RT8039$

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2001

From @nwc10

Created by @nwc10

I was going to stick this on wishlist. Then I RTFM​:

  =item undef

  Undefines the value of EXPR, which must be an lvalue. Use only on

[at which point it implicitly excludes a list]. But why can't I do this​:

perl -we 'undef ($a, $b, $c)'

The error I get is​:

Too many arguments for undef operator at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

A list is an lvalue​:

perl -lwe '($a, $b, $c) = @​INC; print $a; print $b; print $c'
/usr/local/lib/perl5/5.7.2/armv4l-linux
/usr/local/lib/perl5/5.7.2
/usr/local/lib/perl5/site_perl/5.7.2/armv4l-linux

so why can't I undef it?
[and I realise that changing undef to a list operator is not on, but if I
explicitly specific a list, surely that can work. Is there any case where
a list would currently be anything other than that syntax error]

If this is a bug, should we fix the docs to say it is known deficiency?
If this isn't a bug but a feature, should we fix the docs to make it explicit.

Nicholas Clark

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.7.2:

Configured by nick at Sat Nov 17 21:08:50 GMT 2001.

Summary of my perl5 (revision 5.0 version 7 subversion 2 patch 13060) configuration:
  Platform:
    osname=linux, osvers=2.4.5-rmk6, archname=armv4l-linux
    uname='linux bagpuss.unfortu.net 2.4.5-rmk6 #4 tue jun 19 23:26:57 bst 2001 armv4l unknown '
    config_args='-Doptimize=-O1 -Dusedevel -Uinstallusrbinperl [email protected] [email protected] -Dinc_version_list=  -Dinc_version_list_init=0 -Uuse64bitint -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=define
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O1',
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20010319 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldbm -ldb -ldl -lm -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    DEVEL13048


@INC for perl v5.7.2:
    /usr/local/lib/perl5/5.7.2/armv4l-linux
    /usr/local/lib/perl5/5.7.2
    /usr/local/lib/perl5/site_perl/5.7.2/armv4l-linux
    /usr/local/lib/perl5/site_perl/5.7.2
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.7.2:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LC_CTYPE=en_GB.ISO-8859-1
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/sbin:/usr/sbin:/usr/local/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2001

From [Unknown Contact. See original ticket]

On Dec 11, Nicholas Clark said​:

A list is an lvalue​:

perl -lwe '($a, $b, $c) = @​INC; print $a; print $b; print $c'
/usr/local/lib/perl5/5.7.2/armv4l-linux
/usr/local/lib/perl5/5.7.2
/usr/local/lib/perl5/site_perl/5.7.2/armv4l-linux

I would say the elements of a list are potentially lvalues, but a list
itself is immutable.

--
Jeff "japhy" Pinyan japhy@​pobox.com http​://www.pobox.com/~japhy/
RPI Acacia brother #734 http​://www.perlmonks.org/ http​://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2006

From @rgs

undef() is a unary operator. That means that C<undef $a, $b> will
compile, and undefine only $a. The proposed change would break that, and
make the backward compatibility police not happy.

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2006

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

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2006

@rgs - 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