Navigation Menu

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

"${\ ... }" gives list context. #1205

Closed
p5pRT opened this issue Feb 21, 2000 · 7 comments
Closed

"${\ ... }" gives list context. #1205

p5pRT opened this issue Feb 21, 2000 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 21, 2000

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

Searchable as RT2179$

@p5pRT
Copy link
Author

p5pRT commented Feb 21, 2000

From @Abigail

Created by @Abigail

I've reported this many moons ago, but the bug is still present​:

$ perl -wle 'sub foo {wantarray ? "ARRAY" : "SCALAR"} print "${\foo}"'
ARRAY
$

It should print "SCALAR".

Perl Info


Site configuration information for perl v5.5.650:

Configured by abigail at Wed Feb  9 14:15:20 EST 2000.

Summary of my perl5 (revision 5.0 version 5 subversion 650) configuration:
  Platform:
    osname=linux, osvers=2.2.13, archname=i686-linux
    uname='linux alexandra 2.2.13 #5 tue feb 8 15:37:54 est 2000 i686 unknown '
    config_args='-d -Dprefix=/opt/devperl -Doptimize=-g'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
    usesocks=undef useperlio=undef d_sfio=undef
    use64bits=undef uselargefiles=define usemultiplicity=undef
  Compiler:
    cc='cc', optimize='-g', gccversion=2.95.2 19991024 (release)
    cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING -fno-strict-aliasing -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.2.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:
    


@INC for perl v5.5.650:
    /home/abigail/Perl
    /home/abigail/Sybase
    /opt/devperl/lib/5.5.650/i686-linux
    /opt/devperl/lib/5.5.650
    /opt/devperl/lib/site_perl/5.5.650/i686-linux
    /opt/devperl/lib/site_perl/5.5.650
    /opt/devperl/lib/site_perl/5.5.640/i686-linux
    /opt/devperl/lib/site_perl/5.5.640
    /opt/devperl/lib/site_perl/5.00563/i686-linux
    /opt/devperl/lib/site_perl/5.00563
    /opt/devperl/lib/site_perl/5.00562/i686-linux
    /opt/devperl/lib/site_perl/5.00562
    /opt/devperl/lib/site_perl/5.00561/i686-linux
    /opt/devperl/lib/site_perl/5.00561
    /opt/devperl/lib/site_perl/5.00558/i686-linux
    /opt/devperl/lib/site_perl/5.00558
    /opt/devperl/lib/site_perl/5.00557/i686-linux
    /opt/devperl/lib/site_perl/5.00557
    /opt/devperl/lib/site_perl
    .


Environment for perl v5.5.650:
    HOME=/home/abigail
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/home/abigail/Lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib
    LOGDIR (unset)
    PATH=/home/abigail/Bin:/opt/perl/bin:/usr/local/bin:/usr/local/X11/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/games:/opt/povray/bin:/opt/teTeX/bin/i686-pc-linux-gnu
    PERL5LIB=/home/abigail/Perl:/home/abigail/Sybase
    PERLDIR=/opt/perl
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Feb 22, 2000

From @gsar

On 22 Feb 2000 06​:11​:19 GMT, abigail@​delanet.com wrote​:

I've reported this many moons ago, but the bug is still present​:

$ perl -wle 'sub foo {wantarray ? "ARRAY" : "SCALAR"} print "${\foo}"'
ARRAY
$

It should print "SCALAR".

It may have to be called a feature. \ attempts to distribute into
lists, and will therefore will provide list context to anything
that may potentially generate a list. Try ${\scalar foo}.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2000

From [Unknown Contact. See original ticket]

Gurusamy Sarathy <gsar@​ActiveState.com> wrote

It may have to be called a feature. \ attempts to distribute into
lists, and will therefore will provide list context to anything
that may potentially generate a list. Try ${\scalar foo}.

That's completely irrelevant. It should evaluate its argument in the
same context as it was called in. Then lists will automatically
Do The Right Thing.

Note that \@​x, \%x and \&x have to be treated as special cases. But
they're already special cases - \@​a is different from \(@​a).

Note perlfaq4/How do I expand function calls in a string? says​:

  If you prefer scalar context, similar chicanery is also
  useful for arbitrary expressions​:

  print "That yields ${\($n + 5)} widgets\n";

  Version 5.004 of Perl had a bug that gave list context to
  the expression in ${...}, but this is fixed in version
  5.005.

If only ...

Mike Guy

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2000

From [Unknown Contact. See original ticket]

Gurusamy Sarathy <gsar@​ActiveState.com> wrote

It may have to be called a feature. \ attempts to distribute into
lists, and will therefore will provide list context to anything
that may potentially generate a list. Try ${\scalar foo}.

That's completely irrelevant. It should evaluate its argument in the
same context as it was called in. Then lists will automatically
Do The Right Thing.

Note that \@​x, \%x and \&x have to be treated as special cases. But
they're already special cases - \@​a is different from \(@​a).

Note perlfaq4/How do I expand function calls in a string? says​:

If you prefer scalar context\, similar chicanery is also
useful for arbitrary expressions&#8203;:
    print "That yields $\{\\\($n \+ 5\)\} widgets\\n";
Version 5\.004 of Perl had a bug that gave list context to
the expression in $\{\.\.\.\}\, but this is fixed in version
5\.005\.

If only ...

I believe this little excerpt originally derives at least from
Camel-II, and might even have been earlier earlier. In any event,
my recollection is that the bit with ${\(...)} was something that
Mr Wall added to augument the @​{[...]} interpolation case that I
myself had already illustrated. Perhaps he therefore intended that
it work that way.

--tom

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2000

From @gsar

On Wed, 23 Feb 2000 15​:10​:02 GMT, "M.J.T. Guy" wrote​:

Gurusamy Sarathy <gsar@​ActiveState.com> wrote

It may have to be called a feature. \ attempts to distribute into
lists, and will therefore will provide list context to anything
that may potentially generate a list. Try ${\scalar foo}.

That's completely irrelevant. It should evaluate its argument in the
same context as it was called in. Then lists will automatically
Do The Right Thing.

Try implementing that, and please send me the patch when you've finished
it. ;-)

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2002

From @jhi

I'm marking the problem ticket as resolved.

@p5pRT
Copy link
Author

p5pRT commented Nov 28, 2002

@jhi - Status changed from 'open' 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