Use of "caller" is ambiguous

Use of "caller" is ambiguous

am 11.10.2007 19:04:25 von Ferry Bolhar

Hi,

when writing

*{caller . '::vtx_get_page'} = sub {....};

Perl complains with

Use of "caller" without parentheses is ambiguous

Why is this expression ambiguous?

Greetings, Ferry
--

Re: Use of "caller" is ambiguous

am 11.10.2007 19:17:44 von Paul Lalli

On Oct 11, 1:04 pm, "Ferry Bolhar" wrote:
> Hi,
>
> when writing
>
> *{caller . '::vtx_get_page'} = sub {....};
>
> Perl complains with
>
> Use of "caller" without parentheses is ambiguous
>
> Why is this expression ambiguous?

Hmm. I'm not entirely sure. `perldoc perldiag` says about this
warning:
Warning: Use of "%s" without parentheses is ambiguous
(S ambiguous) You wrote a unary operator followed by
something that looks like a binary operator that could
also have been interpreted as a term or unary operator.

But I don't see how that applies here. Obviously, "caller" is the
unary operator, but I don't see how the binary operator "." could also
be interpreted as a term or unary operator. `perldoc perlop`
certainly doesn't make reference to any unary "." operator.

I'm curious to see what other responses you get in this thread...

FWIW, you can reduce the issue to something as simple as:
perl -wle'$x = caller . "foo";'

Paul Lalli

Re: Use of "caller" is ambiguous

am 11.10.2007 23:57:28 von Michele Dondi

On Thu, 11 Oct 2007 19:04:25 +0200, "Ferry Bolhar"
wrote:

>*{caller . '::vtx_get_page'} = sub {....};
>
>Perl complains with
>
>Use of "caller" without parentheses is ambiguous
>
>Why is this expression ambiguous?

I don't know, but I often get the same behaviour with another
construct, which is also surprising. I've never dared to ask and just
added parens without doing so.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: Use of "caller" is ambiguous

am 12.10.2007 01:00:19 von Ben Morrow

Quoth "Ferry Bolhar" :
>
> when writing
>
> *{caller . '::vtx_get_page'} = sub {....};
>
> Perl complains with
>
> Use of "caller" without parentheses is ambiguous
>
> Why is this expression ambiguous?

It's not. However, the analogous expression

caller + 5

*is* ambiguous ( caller(+5) rather than caller() + 5 ) and the warning
code either isn't smart enough to tell the difference, or is assuming
you aren't.

That's my story, anyway, and I'm sticking to it. If I do too much poking
around in toke.c my brain will dribble out of my ears... :)

For example, with 5.8.8:

~% perl -wle'print rand-10'
Warning: Use of "rand-10" without parentheses is ambiguous at -e
line 1.
-5.64649815977649

Ben

Re: Use of "caller" is ambiguous

am 12.10.2007 14:59:30 von Michele Dondi

On Thu, 11 Oct 2007 23:57:28 +0200, Michele Dondi
wrote:

>>Why is this expression ambiguous?
>
>I don't know, but I often get the same behaviour with another
>construct, which is also surprising. I've never dared to ask and just
>added parens without doing so.

I forgot to add that for some reason I can't remember *which*
construct it is, but it was perhaps implicit.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,