On Wed, 1 Dec 2004 00:22:25 +0000, Jonathan Paton <[EMAIL PROTECTED]> wrote:
> Jim,
> 
> > qq:i {}  is just like qq{} except that when it interpolates variables,
> > those which are undefined are preserved literally.
> 
> Interesting idea except for the flaw.

I think we almost have something like this already. Looking at the
updated Synopsis 2, I think you can use closure interpolation with
single quotes like this:

  my $name = 'vars';
  my $code = q:c[ my @{$name} = ($a, $b, $c); ];
  # prints " my @vars = ($a, $b, $c); ";
  say $code;

The problem is that you also need {}'s for subroutines and other
things. But the underlying problem is that using another character to
interpolate doesn't get you anywhere because then you can't use that
in your code.

So... maybe we can pass a parameter saying what we want to use to interpolate?

  my $name = 'add';
  my $code = q:c<«>[
      sub «$name» ($left, $right) {
          return $left + $right;
       }
  ];
  # prints "
  #     sub add ($left, $right) {
  #         return $left + $right;
  #     }
  # "

Where you could whatever you wanted instead of «».

-- 
matt diephouse
http://matt.diephouse.com

Reply via email to