Use of "caller" is ambiguous

F

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
--
 
P

Paul Lalli

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
 
M

Michele Dondi

*{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
 
B

Ben Morrow

Quoth "Ferry Bolhar said:
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
 
M

Michele Dondi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top