RFC 226 (v1) Selective interpolation in single quotish context.
[email protected] (Perl6 RFC Librarian) 14 Sep 2000 21:52:12 -0000
| Newsgroups | perl.perl6.announce.rfc,perl.perl6.language |
|---|---|
| Message-ID | <[email protected]> |
This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Selective interpolation in single quotish context. =head1 VERSION Maintainer: Brad Hughes <[email protected]> Date: Sep. 14, 2000 Mailing List: [email protected] Number: 226 Version: 1 Status: Developing =head1 ABSTRACT Perl6 should allow scalars and arrays to be tagged such that they are interpolated in single quotish context. =head1 DESCRIPTION Single quotish context, such as C<q{}>, C<''>, and specified here-docs, is especially useful for large blocks of text which may contain the C<$> and C<@> characters. Frequently, however, interpolation within that large block of text is desired. This RFC proposes that in single quotish context scalars and arrays may be tagged to be interpolated. As an example, on the VMS operating system the C<$> runs rampant through VMS namespaces, not to mention that each line of VMS' equivalent of a Unix shell script (called a .com file) starts with a C<$>, and execution of VMS .com files is invoked with a C<@>, resulting in backslashitis: print F <<END; \$! \$! execute a.com, copy and purge \$! \$ \@sys\$login:a.com \$ copy $filename sys\$login:*.* \$ purge sys\$login:$filename \$! \$ exit END With this proposal, the scalar C<$filename> can be tagged to be interpolated (for the sake of argument, by doubling the C<$>) and the double quotish context replaced by single quotish context resulting in the following: print F <<'END'; $! $! execute a.com, copy and purge $! $ @sys$login:a.com $ copy $$filename sys$login:*.* $ purge sys$login:$$filename $! $ exit END An array can be tagged by doubling the C<@>. Jarkko's original suggestion was for a different single quotish context with this behavior; this is possible as well, but I see no danger in extending current single quotish context to incorporate this behavior. If a different single quotish context with this behavior is desired, then a new member needs to be added to the C<q(), qq(), qx(), qr()> family, with all the attendant arguing about which letter to use. I find this addition to be most useful for single quotish context here-docs, though, so would argue that it apply to all single quotish context forms. =head1 IMPLEMENTATION This wouldn't seem a difficult change to make. The p526 translator can backslash C<$$\w+>, resulting in C<\$$\w+>, which should give current behavior. =head1 REFERENCES Suggestion by Jarkko Hietaniemi <[email protected]> in <[email protected]>, and seconded by Mark-Jason Dominus <[email protected]> in <[email protected]>.