develooper Front page | perl.perl5.porters | Postings from March 2000

[ID 20000320.007] contradiction in context

Thread Next
Ari Jolma
March 20, 2000 10:47
[ID 20000320.007] contradiction in context
Message ID:
This is a bug report for perl from,
generated with the help of perlbug 1.26 running under perl 5.00502.

[Please enter your report here]

Using this admittedly strange piece of code

#!/usr/bin/perl -w

package Test;

use overload '>' => 'gt';

sub new {
    my $class = shift;
    my $value = shift;
    my $self = {};
    $self->{value} = $value;
    return $self;

sub gt {
    my $self = shift;
    my $cmp_to = shift;
    my $wantarray = wantarray();
    if (defined($wantarray)) {
	print "return value of wantarray() defined\n";
	return $self->{value} > $cmp_to;
    } else {
	print "return value of wantarray() NOT defined\n";
	$self->{value} = $self->{value} > $cmp_to;

$test = new Test 5;

$test > 4;

print $test->{value},"\n";

I get the output:

Useless use of numeric gt in void context at ./ line 31.
return value of wantarray() defined

but man perlfunc tells me: "wantarray ... Returns the undefined value
if the context is looking for no value (void context)."

To me this seems like a contradiction.


Ari Jolma (member of Helsinki Perl Mongers)

[Please do not change anything below this line]

Site configuration information for perl 5.00502:

Configured by root at Fri Nov 12 20:33:30 EET 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
    osname=linux, osvers=2.2.12, archname=i686-linux
    uname='linux 2.2.12 #2 fri nov 12 20:27:54 eet 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
    cc='cc', optimize='-O2', gccversion=
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -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 -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, 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 5.00502:

Environment for perl 5.00502:
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

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