On Mon, Apr 18, 2005 at 11:23:34PM +0300, Roie Marianer wrote: : > : But when you start interpolating, you get into a big mess: : > : h<\qq[$interpolated]> = want(); # ??? : > : h<<$foo>> = want(); # ??? : > : > I think that, as with functions called in unknown context, we should : > just force the RHS here to list context, and rely on the RHS to add : > extra context as necessary if they really mean scalar. If something : > really is always producing a scalar value, it doesn't matter if it's : > called in list context. : : That makes sense, but that would make : %num_of_lines<file> = @file : not DWIM... of course that would translate into : %num_of_lines<file> = scalar @file : so maybe that's OK.
Eh, no, I wouldn't call that one "unknown context". I'd call it scalar. : > Any bit of expression by default evaluates at ordinary run time, but can : > be forced to evaluate earlier by surrounding context. : What you're saying is that : BEGIN { $c=1 } : $c=0; : q:c($c)/.../ : interpolates, because the $c in line three is evaluated after the $c in line : one but before the $c in line two, right? If you don't obfuscate on purpose : (like I did), that makes sense. Yes. The main problem is that you have to make sure the "my $c" isn't hidden in an inner block. This wouldn't work: BEGIN { my $c=1 } $c=0; q:c($c)/.../ Note that my $c = BEGIN { 1 }; doesn't quite work either. However, we'll probably end up my $c will begin { $_ = 1 }; or some such. Compile-time binding my $c ::= 1; probably also works, or maybe you have to write: my $c ::= \1; Larry