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

5.18 VT in \s

Thread Next
From:
Karl Williamson
Date:
November 28, 2012 18:40
Subject:
5.18 VT in \s
Message ID:
50B65AA9.3010907@khwilliamson.com
We experimentally changed m/\s/ to include a vertical tab in 5.17.0. 
There have been no reports of failures regarding this.  I doubt very 
much that we will get any.

I propose that we release this, documented as an experimental change, in 
5.18.  If there is loud protest, we can back it out in 5.20 or 5.22.

Originally, I had proposed a feature to turn this on and off, for 
backward compatibility.  Several people did not want to do this for such 
a small change.

The reason to do this is because Perl's \s doesn't match various 
standards, like Unicode and Posix.  Training materials for Perl are thus 
awkward, and it presents a cognitive burden on Perl programmers.

The reason not to do this is because it is a change from very long 
standing practice, and might break existing code.

It was suggested that people who want to include VT can already write 
[\s\cK] or [\s\013], etc.  Another suggestion was [\h\v].  This last is 
not precisely the same as the others because it matches NEL and NBSP 
under /d, and the others don't.

An obtuse, but short way to exclude VT (if \s includes it, or even if it 
doesn't) is to say [^\S\cK].  The regex set operations that I intend to 
introduce in 5.18 would give a clearer way:
	(?[ \s - \cK ])
(exact syntax of these subject to change).

What we know now is that this change either didn't break anything that 
gets typically tested in CPAN, or the breakage is so subtle as to be 
unnoticeable, so far.

I think it is the former.  The VT is very rare.  And this rarity argues 
for making things easier on the vast vast majority of programs and 
programmers, even if a very few do get broken.  Larry said he did not 
remember why VT was excluded from \s, but had no objection to including 
it now.

I have coded in 5.17 assuming that \s and [:space:] (which includes VT) 
are not necessarily the same.  I am proposing keeping that distinction 
in 5.18 at least, and perhaps 5.20, just in case there is something I 
(and the others who have supported the original proposal) have overlooked.

To repeat the bottom line of this proposal:
Make \s in 5.18 match VT, but document this as experimental.

Only a tiny few programs care.  Perhaps none.

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