develooper Front page | perl.fwp | Postings from July 2003

RE: my if?

Thread Previous | Thread Next
From:
Pense, Joachim
Date:
July 2, 2003 03:10
Subject:
RE: my if?
Message ID:
630BE70C8320D6118D240002A589ABB2088B9FAB@DERUM201
Abigail wrote

> > > > 
> > > > |   sub x {
> > > > |       static $vbl ;
> > > > |       ...
> > > > |
> > > > 
> > > > | {
> > > > |     my $vbl;
> > > > |     sub x {
> > > > |     ...
> > > > |     }
> > > > | }
> > > 
> > > 
> > > IMO, not doubt the latter looks far more elegant - as that 
> > > enables your
> > > 'static' variable to be shared with more than one 
> function. Something
> > > you can't do with a 'static' declared variable inside a function.
> > > 
> > 
> > Mighty != elegant.
> > 
> 
> And neither is not being flexible.
> 

Compare it with conditionals.

You can write

if ($some_condition) {
   do_this;
   do_that;
   do_something_else;
}

and you can write

do_this if $some_condition;

You need not write

if ($some_condition) {do_this}

The first version is more flexible, the second more elegant in its
restricted scope. I think it is Perlish to have both available.

Joachim

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About