in reply to explanation of constant syntax?

I prefer using FOO() and BAR() to prevent this problem. It makes the code clearer because the function calls look like function calls.

- tye        

Replies are listed 'Best First'.
Re^2: explanation of constant syntax? ()
by bart (Canon) on Mar 20, 2004 at 18:25 UTC
    ... except people don't tend to think of constants as "function calls". That's what they are, in Perl, but it's not, er, part of their job description.

      Yep, constants aren't very clear in Perl... unless you write them like FOO(). It clears up what is really going on to the user.

      It also clears up what is going on to Perl. Barewords are quite ambiguous in Perl. Is it a function call, a string, a reserved word, a file handle, a package name, ... ? Sometimes Perl is forced to guess and sometimes guesses wrong (just like in the original node). So I almost always add the trailing parens to make things clear to man and beast.

      One exception is that I sometimes call subroutines that take arguments without the parens to get compile-time notice when I mispel the routine name. But I only do that for statements (never in the middle of an expression), because there are even more ambiguities to trip on.

      - tye        

        I'm not sure that's necessarily helpful. The value of constant subs gets inlined at compile time, so while they share the syntax of function calls they do not share their semantics. There is no function call, even though it looks like one to the reader.

        Makeshifts last the longest.