develooper Front page | perl.perl5.porters | Postings from October 2014

Re: [perl #120790] Unicode::UCD::charscript fails to identify Hanideograph

Thread Previous
From:
Karl Williamson
Date:
October 2, 2014 03:57
Subject:
Re: [perl #120790] Unicode::UCD::charscript fails to identify Hanideograph
Message ID:
542CCD04.9040702@khwilliamson.com
On 12/15/2013 10:25 PM, Karl Williamson wrote:
> On 12/15/2013 05:39 PM, Mark Dominus wrote:
>> Zefram <zefram@fysh.org>:
>>> Karl Williamson wrote:
>>>> Suppose charscript() and friends raised a warning if the code point
>>>> argument passed to them is invalid,
>>>
>>> Sounds good.  Specifically, you want a warning iff the argument would
>>> generate a warning if used in a numeric context.  Because this is a
>>> numeric context.
>>
>> I'm not sure it makes sense to slow down every call to charscript()
>> just to prevent what was actually an RTFM error.
>>
>
> This would slow down only error cases.  As you pointed out, the name of
> the function is misleading.  It seems to me that it would be a
> reasonable thing for us to do to help users cope with that.  It would
> also save this list time by keeping unwarranted bug reports from being
> filed.
>
> One thing to note, though, is the best place to put the warning is in a
> common function used by all the functions in the module to do code point
> argument processing, so the warning would be raised for all such functions.
>

I looked at the cod of Unicode::UCD.  It turns out that most of the 
functions in it croak when they get this type of illegal parameter.  And 
all but two of the rest call carp.  This means that the only two that 
are silent are charblock() and charscript().

And, the context isn't numeric.  The parameter for these two functions 
can be either a number, or the name of a script or block.  If it doesn't 
look like a number, it assumes it is a name, and if there is no such 
name, it returns undef.

It is a trivial matter to add a warning here, which would not add CPU 
time to the success cases.  But I'd like to get more of a consensus as 
to if doing so is advisable

Thread Previous


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