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

Re: my if?

Thread Previous | Thread Next
From:
Abigail
Date:
July 2, 2003 00:46
Subject:
Re: my if?
Message ID:
20030702074551.GA8952@abigail.nl
On Wed, Jul 02, 2003 at 07:58:03AM +0100, Pense, Joachim wrote:
> 
> Even if you are right and not virtually every programmer knows of the
> concept, in my view it is a concept that anyone who started using it
> probably will not like to miss in the future (well, at least it used to be
> my favorite feature of C classic). It enables you to declare variables at
> the latest possible point (the first usage) which is a programming style
> that is often recommended in the Perl community. I think it is easy to see
> which version looks elegant and which one kludgy:
> 
> (Quoted from earlier in the thread, reformatted:)
> 
> |   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.



Abigail

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