On Sun, 30 Jan 2011, Nicholas Clark wrote: > > I'm really not convinced that prototypes (as is) add any value in the general > case. To my mind, they complicate reading the code, because they provide > action-at-a-distance on how the parser is going to treat function calls. > > There seemed to be a fashion for using them extensively around 5.003-5.004 > time (for example, a lot of the regen code in the core), and looking at that > code now, it feels dated to me, and lacking some KISS. I always thought prototypes are primarily for the definition of CORE::GLOBAL::* functions and similar. This thought is somewhat supported by perlsub.pod: Because the intent of this feature is primarily to let you define subroutines that work like built-in functions, here are prototypes for some other functions that parse almost exactly like the corresponding built-in. So I don't think prototypes should be used for "regular" functions that don't try to implement some core-like primitives (e.g. using it for the recently discussed kvmap() function seems sensible). The only exception for non-core-like functions that I find sensible is using the empty prototype for constant functions: $ perl -wE 'sub FOO {3}; say FOO+1' 3 $ perl -wE 'sub FOO () {3}; say FOO+1' 4 Without the prototype the "FOO+1" is parsed as "FOO(+1)" instead of "FOO()+1". Cheers, -JanThread Previous | Thread Next