On Fri, Jan 25, 2002 at 05:07:48PM -0800, Dew-Jones, Malcolm MSER:EX wrote:
> Lets add an .interpolate method.  The parameter(s) are rules that control
> the interpolation, and the returned value is the interpolated string using
> those rules.
> 
>       $result = 'scalar $vars (only) will be interpolated' .
> interpolate($) ;

I'm actually just thinking about how to do interpolation now; I'm basically
using Perl 5 rules for the most part.

The thing that worries me about this idea of yours is that interpolate
certainly looks like a method, but it isn't; the arguments you're passing
in aren't real arguments at all, they're not ordinary Perl syntax. In fact,
you've made up a special tiny domain-specific language for conveying how
to interpolate certain things. Now, there's nothing wrong with tiny
domain-specific languages, given the right domain. For instance, regular
expressions are the right domain. But when you add a little DSL, you have to
tell the parser to stop parsing ordinary Perl, and start parsing something
else. And you want to do this when you see an interpolate method on a string.
Or maybe not just on a string - maybe "interpolate" becomes a special method
on everything, which takes this special syntax. Either way, I'm not sure this
is something you want to be making up new syntax for.

> scenario two, same idea but using =~ notation.

Slightly better, but =~ means "match" in some sense, and that sense is
getting broader in Perl 6. And interpolation doesn't have very much
in common with matching.

-- 
It's a testament to the versatility of the human mind that we're so able 
to compensate for our own incompetence.
    - Darrell Furhiman

Reply via email to