develooper Front page | perl.perl5.porters | Postings from September 2012

Re: Shouldn't \N{unknown name} be a syntax error?

Thread Previous | Thread Next
Karl Williamson
September 9, 2012 16:03
Re: Shouldn't \N{unknown name} be a syntax error?
Message ID:
On 06/14/2011 09:48 PM, Jesse Vincent wrote:
> On Tue, Jun 14, 2011 at 07:43:50PM -0600, Karl Williamson wrote:
>> The current behavior of \N{} when it can't find the name is to raise
>> a warning and return the REPLACEMENT character.  This seems wrong to
>> me, as it is a compilation-time construct, and every other place I'm
>> familiar with bails out under such circumstances.
>> Changing this would not have backwards compatibility issues, since
>> the likelihood of someone deliberately using this to insert a
>> REPLACEMENT character into a string seems vanishingly small to me.
> The two parts of that sentence aren't quite as connected as I'd like.
> "would not have backwards compatibility issues" is a very strong
> statement for "turn a warning into an error."
> -j

To rephrase slightly, the reason I claim that this does not have 
backwards compatibility issues is that currently an unknown name is 
turned into a REPLACEMENT CHARACTER.  The only purpose for that 
character in the Unicode standard is to signify that the character you 
really wanted was mangled somehow; with no further information 
available.  Thus the only reason for a programmer doing this on purpose 
is as an obfuscated way to input a REPLACEMENT character in your code. 
And, since a warning is generated, it's not really obfuscated.

And now, Unicode has revised their advice on regular expressions and 
they now say the same thing:

"The \N syntax should instead cause a syntax error for an undefined name"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About