develooper Front page | perl.perl5.porters | Postings from September 2019

[perl #125557] add hexfloat support to constant overloads

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
September 9, 2019 05:30
Subject:
[perl #125557] add hexfloat support to constant overloads
Message ID:
rt-4.0.24-21822-1568006997-791.125557-15-0@perl.org
On Wed, 05 Aug 2015 12:37:58 -0700, perl.p5p@rjbs.manxome.org wrote:
> * Tony Cook via RT <perlbug-followup@perl.org> [2015-08-05T02:30:07]
> > Maybe instead of allocating a bit to each type of overloading we
> > should only
> > use a single bit to indicate there *some* sort of constant
> > overloading
> > happening, and toke.c then checks $^H{whichever} to decide if that
> > particular
> > type of constant should be overloaded.
> >
> > This would slow down compiling code that uses any overloaded constant
> > type,
> > but I'd expect that to be fairly rare (maybe I'm wrong), and would
> > free up 4
> > bits in PL_hints for other uses.
> 
> I also guess this is quite rare.  That's a guess, mind you.  I would
> further
> guess that the largest that constant overloading gets into programs is
> bignum
> and brethren, for whatever that is worth.
> 
> I don't really have an opinion on how to proceed, but lean toward
> agreement
> with Karl.

It turns out this old bug isn't really an issue:

tony@mars:.../git/perl$ cat biggish.pm
package biggish;
use overload;

sub import {
    overload::constant float => sub {
        my ($str, $type, $usage) = @_;
        print STDERR "Called: @_\n";
        return eval $str;
    };
}

1;
tony@mars:.../git/perl$ ./perl -Ilib -I. -Mbiggish -wle 'print 0x0.1p1'
Use of uninitialized value in join or string at biggish.pm line 7.
Called: 0x0.1p1 0.125 

0.125

The usual float handler is called even for hex floating point constants.

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=125557

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About