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

Re: We need to consider Unicode variable names for 5.16

Thread Previous | Thread Next
From:
John Imrie
Date:
October 10, 2011 11:31
Subject:
Re: We need to consider Unicode variable names for 5.16
Message ID:
4E9339E0.2040603@virginmedia.com

>      What about normalization, etc.
>
>
> https://rt.perl.org:443/rt3//Public/Bug/Display.html?id=96814
>
> I had a branch somewhere that implemented a very simple pragma (use 
> normalized identifiers => "NFD"), which started off pretty well, but I 
> quickly got stumped as I couldn't get direct stash manipulation right 
> in all cases.
> That "worked" (for some definitions of working, of course :P) by 
> calling Unicode::Normalize::normalize, but a final implementation 
> should probably inline some normalization form into the core, and use 
> Unicode::Normalize::normalize as a fallback.
>
Unicode Standard Annex #31 Unicode Identifier and Pattern Syntax 
recommends NFC rules prevail.
I would like to suggest that in the scope of a 'use utf8' any identifier 
added to the stash or a pad is passed through Unicode::Normalize::NFC 
before being so added. This could be done by making the stash and pad 
magical when adding or manipulating a key.

This has the following benefits/costs

    1) Individual scripts and packages may be in any normalisation form
    but identifiers will be compared in a known way
    2) Anything not using utf8 will still be backwardly compatible.
    3) Anyone comparing an element in the stash or pad to a string under
    'use utf8' will have to normalize the string before comparison. But
    If you are playing at that level I would like to assume that you
    know what you are doing.
    4) Exporter and Sub::Exporter and friends will now have to take
    account of the utf8-ness of the environment and normalize their
    parameters appropriately. I decided to do it this way rather than
    force 'import' to do an implicit normalization as at this level of
    Wizardry you should be able to do your own magic and not have things
    forced on you.

John




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