On Thu, Jul 22, 2004 at 11:16:09AM -0500, Dan Hursh wrote:
: Larry Wall wrote:
: >    No          Yes
: >    --          ---
: >    @foo        @foo[1]
: >    %bar        %bar{"a"} or %barŤať
: >    $foo.bar    $foo.bar()
: >    &foo     &foo(1)
: 
: I may have missed it, but what are the contexts in these cases?  I'm 
: thinking the first two are easily scalar.  Are the second list just as 
: if they were inside curly braces, or are the scalar to match the others 
: (or just to be flexibly different)?

I tend to like the flexibly different approach.  On the other hand,
that doesn't say what to do if such a method or sub actually returns a
list in scalar context, and whether that's the same thing that would
happen inside curlies.  We could distinguish those, rather like Perl
5 distinguishes these:

    print "@foo",\n";
    print @foo,"\n";

People certainly learned to deal with that little non-orthogonality.
On the other hand, it might be viewed as gratuitously fiddly to make

    print "@x.sort()\n";
    print "[EMAIL PROTECTED]";

interpolate differently.  I don't profess to have an opinion on it yet.

: >In this worldview, $foo is an exception only because it doesn't naturally
: >have a form that ends with some kind of bracket.
: 
: Will "$x[$y]" interpolate?

Certainly.  Likewise "$x{$y}".  (Presuming we keep the end bracket rule.)

: Oh and if $x is a reference to an array, is 
: "$x" a stringified reference or dereferenced (and in which context)?

In any string context, the default will be to dereference references
to a real value.  That includes list contexts embedded within a string
context, as bare {} would supply.  The main question is when to get
fiddly about supplying spaces between the values.

: I got it in my head that since things in curlies would be in list context 
: that the others must be scalar/string context.

They're all ultimately in string context, but curlies would do it
via list context.  It would make no difference for functions that
always return scalars in list context, and little to no difference for
functions that always return lists regardless of context (depending
on how we fiddle it).

: I haven't been able to 
: find a reason for justifing that leap, but I kind of like it.  Well for 
: the moment.

Yeah, me too...this week...

Larry

Reply via email to