This and other RFCs are available on the web at
  http://dev.perl.org/rfc/

=head1 TITLE

Variable interpolation on demand.

=head1 VERSION

  Maintainer: Glenn Linderman <[EMAIL PROTECTED]>
  Date: 14 Sep 2000
  Mailing List: [EMAIL PROTECTED]
  Number: 229
  Version: 1
  Status: Developing

=head1 ABSTRACT

Make Perl's powerful string interpolation facilities are available to
variables, in addition to literals.

=head1 DESCRIPTION

Given:

        $foo = 'def';
        $bar = 'ghi';
        $x = "abc$foo$bar";
        $y = 'abc$foo$bar';

There is no  way to turn obtain the  value of $x from the  value of $y.
In other  words, while  $foo and $bar  were interpolated into  $x, they
were not interpolated into $y.  It would be nice to get Success! from:

        $z = interpolate ( $y );
        print 'Success!"  if $z eq $x;

However,  there  is  no  direct  language facility  for  this,  because
interpolation only happens one level  deep (which is good), so attempts
such as

        $z = qq/$y/;

will interpolate $y, but not $foo and  $bar, so $z eq $y, instead of $z
eq $x.

Shown above is a functional  syntax.  However, due to scoping rules and
lexical  variables, it  is unlikely  that this  functionality  could be
implemented as a  function, more likely it would have  to be a keyword.
An alternate syntax might be:

        $z = qd/$y/;

implying a double interpolation pass.  Or

        $z = q2/$y/;

which means 2 interpolation passes,  and which could be extended to q3,
q4, q5 ???  Or

        $z = qq/$y/2;

which likewise would mean two passes, and could be extended to 3, 4, 5,
or even to

        $z = qq/$y/$n;

a  variable number  of passes.   The same  could be  achieved  with the
keyword technique via an additional parameter:

        interpolate ( $y, $n );


=head2 Compatibility considerations

This is a new feature, so name conflict is the only issue.

=head1 IMPLEMENTATION

Just a re-write rule.

=head1 REFERENCES

None.


Reply via email to