Re: variable declaration, was RE: moving to the next line
From: Chris Devers (cdevers_at_pobox.com)
Date: 12/17/04
- Previous message: Paul Johnson: "Re: variable declaration, was RE: moving to the next line"
- In reply to: Paul Johnson: "Re: variable declaration, was RE: moving to the next line"
- Next in thread: Lawrence Statton: "Re: variable declaration, was RE: moving to the next line"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 17 Dec 2004 12:06:36 -0500 (EST) To: Paul Johnson <paul@pjcj.net>
On Fri, 17 Dec 2004, Paul Johnson wrote:
> On Fri, Dec 17, 2004 at 09:17:05AM -0500, Chris Devers wrote:
>
> > On Thu, 16 Dec 2004, Charles K. Clarkson wrote:
> >
> > > Don't declare all your variables at the beginning
> > > of the script. It works in other languages, but not
> > > in perl. Declare them as you go.
>
> I suppose that depends on your definition of "works".
>
> > Out of curiosity, why this rule?
>
> Locality of reference.
Meaning... declare it where you use it, QED ?
The counterargument to that might be "spagetti code, QED".
That is, if you declare everything at the last possible line, then
there's no clear organization of what data is being tracked in a given
segment of code. On the other hand, if you cluster the declarations a
bit -- not globally, but lexically -- then to my thinking things are
clearer.
This isn't something I feel strongly about one way or the other. I just
find it striking that the advice given out on this list differs so
starkly with the practice that I have been taught (and have seen other
people doing in their code) in the past.
-- Chris Devers
- Previous message: Paul Johnson: "Re: variable declaration, was RE: moving to the next line"
- In reply to: Paul Johnson: "Re: variable declaration, was RE: moving to the next line"
- Next in thread: Lawrence Statton: "Re: variable declaration, was RE: moving to the next line"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|