Nathan Wiger wrote:
> 
> > Foo::Bar->stickysnort()
> 
> Right, knew I forgot something...
> 
> > I wonder whether the "I want to expand arbitrary expressions within
> > strings even when there aren't any $ or @ symbols about" people
> > just need better familiarity with the alternatives.
> 
> This was all spawned by a consistency argument brought up by Bart on
> "where to draw the line" with having -> interpolate:
> 
> http://www.mail-archive.com/perl6-language@perl.org/msg03658.html
> http://www.mail-archive.com/perl6-language@perl.org/msg03659.html
> 
> If instead we chose to draw the line at needing a $, I'm fine with that,
> as long as the line is well-defined and allows for class methods to
> interpolate in qq// strings.

Not entirely unrelated:

Last weekend I got tired of writing

print "Reduced symbol ".$parser->dump_sym($sym)." via rule
".$parser->dump_rule($r).", went to state
".$parser->dump_kernel($k)."\n";

and wrote a very simple module, let's call it Magic:

use Magic;
my (%DSym, %DRule, %DKernel);
register_magic(\%DSym, 'dump_sym', $parser);
register_magic(\%DRule, 'dump_rule', $parser);
register_magic(\%DKernel, 'dump_kernel', $parser);
.
.
.
print "Reduced symbol $DSym{$sym} via rule $DRule{$r}, went to state
$DKernel{$k}\n";

Much nicer. You can even use this to replace map:

register_magic(\%Size, sub { -s $_[0] });
@sizes = @Size{@filenames};

Define the map function once, use it all over the place. (Slowly. This
is using tie()).

More relevant to the current discussion,
register_magic(\%ID, sub { $_[0] });
print "f(1,2,3) = $ID{f(1,2,3)}\n";

Does anyone remember who I stole this idea from? mjd, I think. Ah, yes,
here it is: Interpolate.pm.
<http://www.plover.com/~mjd/perl/Interpolation/>. Some minor
differences.

Reply via email to