Front page | perl.perl5.porters |
Postings from March 2000
[ID 20000320.007] contradiction in context
Thread Next
From:
Ari Jolma
Date:
March 20, 2000 10:47
Subject:
[ID 20000320.007] contradiction in context
Message ID:
200003201850.UAA00475@ariel.hut.fi
This is a bug report for perl from ajolma@water.hut.fi,
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;
bless($self,$class);
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 ./test.pl line 31.
return value of wantarray() defined
5
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.
Regards,
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:
Platform:
osname=linux, osvers=2.2.12, archname=i686-linux
uname='linux ariel.hut.fi 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
Compiler:
cc='cc', optimize='-O2', gccversion=2.7.2.3
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:
/usr/lib/perl5/5.00502/i686-linux
/usr/lib/perl5/5.00502
/usr/lib/perl5/site_perl/5.005/i686-linux
/usr/lib/perl5/site_perl/5.005
.
---
Environment for perl 5.00502:
HOME=/home/ajolma
LANG (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/pgsql/bin:/home/ajolma/bin:/usr/local/java/bin:/usr/X11R6/bin:/usr/local/pgsql/bin:/home/ajolma/bin:/usr/local/java/bin
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Next
-
[ID 20000320.007] contradiction in context
by Ari Jolma