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

RE: my if?

Thread Previous | Thread Next
From:
Pense, Joachim
Date:
July 1, 2003 23:58
Subject:
RE: my if?
Message ID:
630BE70C8320D6118D240002A589ABB2088B9D35@DERUM201
Abigail Wrote

> 
> On Tue, Jul 01, 2003 at 02:37:16PM -0400, Bernie Cosell wrote:
> 
> > Virtually EVERY programmer knows what a simple static 
> variable is -- and 
> 
> I doubt that. A lot of programming languages don't know the concept
> of static variables. And even in languages that do, it isn't used that
> often.  Not every Perl programmer nowadays came by the way of 
> C. Not by
> a long shot.
> 

The concept can be traced back to ALGOL60's "own" variables (not counting
languages like FORTRAN where everything's static anyway).

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 {
|     ...
|     }
| }

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