develooper Front page | perl.perl5.porters | Postings from January 2010

Re: [perl #71762] vianame() returns a chr instead of an ord whencalled like U+xxxx

Thread Previous
From:
karl williamson
Date:
January 2, 2010 11:36
Subject:
Re: [perl #71762] vianame() returns a chr instead of an ord whencalled like U+xxxx
Message ID:
4B3FA035.1070209@khwilliamson.com
demerphq wrote:
> 2009/12/31 karl williamson <perlbug-followup@perl.org>:
>> # New Ticket Created by  karl williamson
>> # Please include the string:  [perl #71762]
>> # in the subject line of all future correspondence about this issue.
>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=71762 >
>>
>>
>> This is a bug report for perl from khw@khw-desktop.nonet,
>> generated with the help of perlbug 1.39 running under perl 5.11.3.
>>
>>
>> -----------------------------------------------------------------
>> The function vianame() in charnames.pm is supposed to return the ordinal
>> of the name it is called with.  But when called with a name like U+0041,
>> it doesn't, it returns the chr instead.
>> -----------------------------------------------------------------
>> ---
> 
> This is actually documented somewhere, i remember being really
> surprised about it when i encountered it.
> 
> Yves
> 
> 

I looked for the documentation of it and didn't find it.  Perhaps you're 
thinking of my email about this subject some months ago.  Here is the 
relevant portion with your response:

> -------- Original Message --------
> Subject: Re: vianame returns either chr or ord
> Date: Tue, 1 Sep 2009 14:42:00 +0200
> From: demerphq <demerphq@gmail.com>
> To: karl williamson <public@khwilliamson.com>
> CC: Perl5 Porters <perl5-porters@perl.org>, Jarkko Hietaniemi 
<jhi@iki.fi>
> References: <4A9C93F3.7050309@khwilliamson.com>
>
> 2009/9/1 karl williamson <public@khwilliamson.com>:
> > If charnames::vianame is called with a name of the form U+XXXX, it 
 > > converts
> > the result with chr before returning.  With any other name it 
returns the
> > ordinal number.  This seems like a bug to me, but I want to make 
 > > sure I'm
> > not missing something.
>
> It looks like it was deliberate, although possibly accidental. See below.
>
> > [snip]
>
> A little digging reveals the "return a char
> for U+" was introduced with the first time vianame() started handling
> U+:
>
> 
http://perl5.git.perl.org/perl.git/commitdiff/dbc0d4f2f139c3775c592bb9d20ada906e3aa68e?hp=f76b0f6998c929fc8d564ca3ed8728a19879ebc7
>
> which makes some sense as it was added to support \N{U+...} processing.
>
> Yves

So the question becomes should the function be bimodal?  I don't think 
so, hence  the bug report.  The module's documentation says it returns 
an ord, so either the documentation is wrong or the implementation is 
wrong.  On principal, I don't like bimodal functions, so it seems to me 
that the documentation is right and the implementation wrong.

Does anyone think that the code shouldn't be changed?


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