in reply to Function Prototype Context Conversion
why can't @foo be treated as an implicit list for DWIM purposes?
What DWIM purposes? You want a scalar as first argument to foo, so Perl is doing exactly that, evaluating the first argument of foo in scalar context.
This is a known issue with prototypes, and one of the reasons prototypes in Perl are often thought of a "a failed experiment". If you prototype foo as taking one scalar as argument, and you want foo @foo to succeed, what's the point of using a scalar prototype? Any argument is going to be scalar anyway. The only "use" could be to fail if @foo != 1. But that means you cannot do prototype checking at compile time, but have to defer it to runtime. But the neat thing about prototypes is compile time checking.
Abigail
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Function Prototype Context Conversion
by tadman (Prior) on Jun 13, 2002 at 13:02 UTC | |
by Abigail-II (Bishop) on Jun 13, 2002 at 13:14 UTC |