Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

quoting characters

10 views
Skip to first unread message

Nicholas Clark

unread,
Jan 1, 2005, 5:01:12 PM1/1/05
to perl6-c...@perl.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

Patrick R. Michaud

unread,
Jan 2, 2005, 10:21:57 AM1/2/05
to Nicholas Clark, perl6-c...@perl.org
On Sat, Jan 01, 2005 at 10:01:12PM +0000, Nicholas Clark wrote:
> 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{}.
> [...]

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

Yes, I would expect so, although I hadn't thought of using ASCII 0 as
quoting characters -- that's a neat trick. I'll keep it in mind as we
progress. :-)

Pm

0 new messages