[Beowulf] Re: g77 limits...

David Mathog mathog at caltech.edu
Thu Mar 2 08:18:31 PST 2006


Robert G. Brown wrote:
> On Wed, 1 Mar 2006, Leif Nixon wrote:
> 
> >> Nesting levels of 10+ are not unknown.
> >
> > Embarrassing. I'll pretend I didn't read that.
> 

There is another way of representing nesting depth besides braces
and indentations: state the nesting depth explicitly.  However, no
language I know of has implemented this method. Probably because it is
ugly as plain text and it also requires a smart editor to
handle a cut and paste operation correctly because it must renumber
indentation levels to match the insertion point.  Ie, the place
where a normal cut and paste of indented text also goes wrong.
On the plus side the logic depth is explicit and all lines start
at the same column near the left side of the screen, so
renormalization of indent levels is avoided.  While it is a
bit hard to read as plain text, it would be trivial to modify
nedit or other graphical editors to highlight indent levels,
or to color them differently, making the nesting visually obvious.
Notice that the braces in the example are logically redundant
because two consecutive lines like 2)->3) correspond to an open
brace and 3)->2) to a close brace. 

That is, do it like this (assuming it was added to C):

#include <stdlib.h>           /* implicit level 0 */
0) #include <stdio.h>         /* explicit level 0 */
0) #include <unistd.h>

   int  main(void){
1) int  i,j,k;                /* explicit levels >0 */
1) int  sum=0;
1)
1) for(i=0; i<10; i++){
2) for(j=0; j<i;  j++){
3) for(k=0; k<j;  k++){
4) sum +=k;
3) }
2) }
1) }
1) (void) fprintf(stdout,"The sum is %d\n",sum);
1) exit(EXIT_SUCCESS);
}


Regards,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech



More information about the Beowulf mailing list