[% setvar title Selective interpolation in single quotish context. %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/

TITLE

Selective interpolation in single quotish context.

VERSION

  Maintainer: Brad Hughes <brad@tgsmc.com>
  Date: 14 Sep 2000
  Last Modified: 14 Sep 2000
  Mailing List: perl6-language@perl.org
  Number: 226
  Version: 2
  Status: Developing

ABSTRACT

Perl6 should allow scalars and arrays to be tagged such that they are interpolated in single quotish context.

DESCRIPTION

Single quotish context, such as q{}, '', and specified here-docs, is especially useful for large blocks of text which may contain the $ and @ 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 $ 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 $, and execution of VMS .com files is invoked with a @, 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 $filename can be tagged to be interpolated by the \I...\E pair 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 \I$filename\E sys$login:*.*
        $ purge sys$login:\I$filename\E
        $!
        $ exit
        END

An array can be similarly tagged. Would \I&subr\E call subr?.

IMPLEMENTATION

This wouldn't seem a difficult change to make.

REFERENCES

Originally suggested in a different form by Jarkko Hietaniemi <jhi@iki.fi> in <archive address to follow>, and seconded by Mark-Jason Dominus <mjd@plover.com> in <archive address to follow>. Version 2 tag pair suggested by Damian Conway in <...>.