develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123814] grok_atou() for regexp quantifiers

Thread Previous | Thread Next
From:
Jarkko Hietaniemi via RT
Date:
February 19, 2015 02:45
Subject:
[perl #123814] grok_atou() for regexp quantifiers
Message ID:
rt-4.0.18-3194-1424313947-1817.123814-15-0@perl.org
NOW would be the time to fix the API of grok_atou.

It was invented some time last summer by yours truly as a less
insane replacement for atoi() (which has a bunch
of its own problems, and which the core was using left and right).

Why NOW?  Because it has been only in 5.21.x, *and* only used by the
core.  So before it escapes the lab, please fix it as you see fit.

Off-hand, maybe it should have a special-special case of
/^0+/ becoming zero.  Maybe.  As Hugo pointed out, the ugly
octal case rears its 010 head.  Or maybe make it return
boolean - in which case it cannot be an atoi drop-in-replacement any more.

The design directive of grok_atou was "accept only strictly valid decimal positive
integers, reject anything else".  "000000" fails that.  But maybe the rejection
should be signaled by the primary return type.

In which case it might as well be removed, no need to tinker
with its docs.  More importantly, no need to keep multiplying APIs.
We have already enough of them.

But PLEASE, fix it.  Or kill it.  (I would but I lack the tuits right now,
in the fast oncoming 5.22 track)





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

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