Bob Showalter wrote at Wed, 05 Jun 2002 15:30:29 +0200:

> 
> 3. Don't use the &foo or &foo(args) calling styles.
> 

Allthough I would miss it a little bit.
I find the &foo style useful when implementing a little polymorphic subroutine.

Example:

sub foo {
      /NUMERIC/        &&       &_foo_numeric
  or  /WORD/           &&       &_foo_word
  or  "otherwise"      &&       &_foo_crazy;
}

sub _foo_numeric {
  print "Numbers: @_\n";
}

sub _foo_word {
  print "Words: @_\n";
}

sub _foo_crazy {
  print "Crazy: @_\n";
}

foo(NUMERIC => (4,5,6));
foo(WORD    => ("x","y","z"));
foo(BIGJ      => ("the greatest"));

It's more practical than writing
_foo_numeric( @_ )
_foo_word   ( @_ )
_foo_crazy  ( @_ )
in the switch case. (In addition I reduce the redundances).

Allthough, there are better (and slower :-( ) 
ways to implement polymorphic in a real OO-style,
I often use the upper behaviour in CGI scripts.

Cheerio,
Janek

PS: I hope that won't become a religious dibute of using &foo - style vs foo() style.
All I wanted was to declare that there are some really useful reasons for the &foo 
style.
I want to underline Bob in saying: Don't use the &foo style without special reason.
Especially don't use it mixed with the foo() style.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to