develooper Front page | perl.perl5.porters | Postings from July 2009

Re: [perl #62056] Variable expansion in same regex as \N{} escape results in compilation error.

Thread Previous
From:
Rafael Garcia-Suarez
Date:
July 17, 2009 00:55
Subject:
Re: [perl #62056] Variable expansion in same regex as \N{} escape results in compilation error.
Message ID:
b77c1dce0907170055l3ff1b309sb150670588ef32ac@mail.gmail.com
2009/7/16 Ben Morrow <ben@morrow.me.uk>:
> Quoth schwern@pobox.com (Michael G Schwern):
>>
>> Seems to me the problem is there's not just one charnames.  There's lots of
>> them.  :full, :short, :alias, greek, cyrillic... and you can even define you
>> own.  How do you know which one is in use?
>>
>> This comes down to how charnames works.  There's not a big table somewhere,
>> you export a "translator" function... which probably looks at some big table
>> on disk.  But it means only one translator can be in effect at any given time.
>>  This seems to me like overkill.
>>
>> On the one hand, who cares?  Its not like its bad if there are too many
>> charname symbols.  Consider \N{...} a big namespace and leave it up to the
>> charnames authors to be polite and not clobber each other.
>
> But what about
>
>    ~% perl -E'
>        {use charnames "latin";
>            say charnames::viacode(ord "\N{upsilon}")}
>        {use charnames "greek";
>            say charnames::viacode(ord "\N{upsilon}")}'
>    LATIN SMALL LETTER UPSILON
>    GREEK SMALL LETTER UPSILON
>
> and other cases of conflict? One of the points of charnames is to avoid
> having to say LATIN SMALL LETTER BLAH WITH MANY EXTRA VERY VERBOSE
> DIACRITICALS all the time, in favour of shorter but ambiguous names: it
> would be a shame to lose that.

Good point. I like Yves' suggestion, because it's simple. I think that
Karl was doing something about the ambiguous names you're pointing to,
but I might be wrong. Also:

$ perl -E '
use charnames qw(greek latin);
say charnames::viacode(ord "\N{upsilon}");
'
LATIN SMALL LETTER UPSILON

$ perl -E '
use charnames qw(latin greek);
say charnames::viacode(ord "\N{upsilon}");
'
LATIN SMALL LETTER UPSILON

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