On Dec 12, 2003, at 12:18 PM, Rob Dixon wrote: [..]

Erm, do you agree with me or not?


Rob

yes and NO!


The yes part being that there are times and places
where good perl coders know which rules to break and why.
Hence, gosh there is that assertion

no strict 'refs';

The No Part will take a bit of explaining, and hence
I will return to your illustration, which was a part
of why I thumped you on the Kanuddle, and also at wiggins,
who I fear wigged out a bit with the PerlPolice gag, which
I still thought was generically cuddly.

ok, so I loaded your demonstration code into my handy
dandy bbedit tool, and proceeded to execute it. I of course
took 'six warnings' of the form
        "useless use of a constant in a void context"

because of course my default templates use '-w'
{ old guy syndrome } and of course the obligatory

use strict;

which is to be expected when one puts constants
into a void context...

So props for neatish illustrative code. But given
the generalized assertions about it being a list
operator, one would have expected-ish

        my @list = qw/bob ted carol alice and bobo fep/;
        subB @list;

would have worked-ish.... but of course
one now gets the error message
        
    Line 16:  Array found where operator expected at end of line
        Line 16:  syntax error near "subB @list"

Which of course is a wonderful place to step off
and discuss say perl's distinction between a list
and an array at the hard corp technical level,
even though we 'blur' that with 'in a list context'...
But unfortunately you 'oopsied' that part, although
were cool enough to note that with the 'predeclare'
portion is required to prevent the 'syntax error'.

So while Tom was being 'polite' with the assertion
of 'style' - there is a somewhat stronger argument
that rests upon 'use strict' and 'use warnings'.

If one had to 'pre-declare' the function to get
perl to stop whining about something, one may
want to go back and REALLY search out what was
happening that made the perl runtime compiler
go WOOF there.

So the idea of using () as IF it was not merely
a 'list contexting' gambit but also a part of
"function"/"method" name, eg:

subB(@list);

not only makes the code LOOK like it is a normal
function call, but it just happens to also do
what one would expect it to do. In like manner
when one gets on through to the classical 'dispatcher'
types of solutions

$process->{$cmd}->();

one has EXPRESSLY asserted that one is Honest To God
INTENDING that the function be passed a 'void' array.


now let us return one last time and posit the question of what would happen in your demonstration code with

subB ;

and why exactly it is that the whiney machine throws the
        Line 18:  Bareword "subB" not allowed while "strict subs" in use

but has no problem with say

subB();

or the less pleasant, to moi,

&subB ;

Which I am compelled to show here, for the obligatory
sense of 'completeness'.

So while Tom, probably a Polite College Man, the sort
that will make a solid 'officer and a gentleman' probably
has social class obligations to be 'friendly' - as an
old fashion 'lower decks man' - I have little problem
with grabbing 'bording pikes' and, well going over the rail...


ciao drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to