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

Re: Thoughts Towards Type Assertions (was: Re: Pre-RFC: builtin::functions for detecting numbers vs strings)

Thread Previous | Thread Next
From:
demerphq
Date:
February 26, 2022 07:34
Subject:
Re: Thoughts Towards Type Assertions (was: Re: Pre-RFC: builtin::functions for detecting numbers vs strings)
Message ID:
CANgJU+VTSzBD9NjJcJau_QG2-SiSzZ7zVT0zf718JMhwnN1giA@mail.gmail.com
On Fri, 25 Feb 2022 at 17:40, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> On Fri, 25 Feb 2022 17:21:58 +0100
> demerphq <demerphq@gmail.com> wrote:
>
> > On Thu, 24 Feb 2022 at 17:31, Paul "LeoNerd" Evans
> > <leonerd@leonerd.org.uk> wrote:
> >
> > > At this point I suddenly don't even like the word "Type". But
> > > currently I don't have a better one - words like "nature", "facet",
> > > "ability" or "capability" all feel wrong somehow.
> > >
> >
> > This reminds me of looks_like_a_number() which pops up all over the
> > place. And I wonder if we even need to have a test for "looks like
> > text", if we have tests for everything else then the only thing left
> > is "text" (without getting into debates about whether the text is
> > pure-octets, or unicode or whatever).
>
> Yes; indeed when briefly discussing these "was originally
> number/string" functions on the PSC call today, Rik mentioned
> looks_like_a_number. It's quite similar on intent and naming scheme.
>
> I also note that we don't (yet) have a builtin::looks_like_a_number so
> perhaps there'd be scope for adding all three of these together, where
> the documentation can point out to would-be users of
> "was_originally_number" that they almost-certainly didn't want that
> function and should instead consider "looks_like_a_number".
>

FWIW, I would be strongly in favour of this. I have seen tons of code doing
looks_like_a_number using regexes, and it is dog slow in comparison to
doing it in C.

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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