develooper Front page | perl.perl6.compiler | Postings from January 2005

quoting characters

Thread Next
From:
Nicholas Clark
Date:
January 2, 2005 02:33
Subject:
quoting characters
Message ID:
20050101220112.GF25432@plum.flirble.org
Something that I've just found useful, and might prove useful for the perl 6
compiler somewhere...


In Perl 5 ASCII 0 bytes are valid in source code. As they're not identifier
characters [ :-) ] this means that they're valid as quoting characters for
things like q{}. Although they can't be stored inside C strings, the
Perl 5 tokeniser has no problem with them. This makes them rather useful,
as they can be used as delimiters around snippets of code generated
inside the compiler, where the snippet came in as a C string, as you can
guarantee that they won't appear *in the middle* of your snippet, so you
don't need to faff with parsing it and quoting a delimiter string.

Rafael used them to solve a bug when patch names had perl code in them:

http://public.activestate.com/cgi-bin/perlbrowse?patch=22850

and I've just used them to eliminate a lot of parsing and quoting code in
the Perl 5 tokeniser where it converts the -F flag to perl code:

http://public.activestate.com/cgi-bin/perlbrowse?patch=23727


I'm assuming that the insides of the Perl 6 compiler are going to be
equally agnostic of ASCII 0 bytes.

Nicholas Clark

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