Hi Arjen:

I changed the subject line to something more appropriate.

On 2012-02-20 10:23+0100 Arjen Markus wrote:

> Hi Alan,
>
> I too come from a school where all declarations are put at the top
> of a program unit, but it seems more and more "fashionable" to restrict
> the scope of variables as much as possible, in this case the variables
> s and p. The code in csa.c is full of that type of local declarations.

Actually, I generally like that fashion/style. If you declare the
variables at the top of the smallest block of code (delimited by "{"
and "}") where they are used (as opposed to declaring them at the top
of the largest possible block of code, i.e., the function where they
are used) I just think it makes the code a lot easier to read and helps
you to keep better track of communication of data between blocks
of code.

As stated previously in this thread, I was a bit concerned from the
efficiency perspective with the case of declarations in a block of
code for a loop, but I am also pretty sure your friend is right (that
compilers will do the right thing from the efficiency perspective and
move the stack allocations/deallocations associated with the
declaration outside the loop).

Is there anyone else here with thoughts or experience with this
largely stylistic issue?

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to