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

RE: my if?

Thread Previous | Thread Next
Pense, Joachim
July 1, 2003 23:58
RE: my if?
Message ID:
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 {
|     ...
|     }
| }


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About