[Beowulf] Re: g77 limits...

Robert G. Brown rgb at phy.duke.edu
Thu Mar 2 10:04:47 PST 2006


On Thu, 2 Mar 2006, David Mathog wrote:

> 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);
> }
>

Lovely.  Great idea.  emacs does some stuff like this with xml and tags,
but I've never seen it do it with C code.  Probably does, though, if you
could only find the right lisp modules.

I could add this to jove pretty easily as well, as I have the source.
However, if it isn't in the language itself, then you're left with
either numbers in that don't parse and printing and browsing in other
environments won't work.  So it would have to be a language level
modification, and peoples eyes and hands (all used to indentation from
computer language infancy in ALL languages) would have to retrain.

    rgb

>
> Regards,
>
> David Mathog
> mathog at caltech.edu
> Manager, Sequence Analysis Facility, Biology Division, Caltech
> _______________________________________________
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
>

-- 
Robert G. Brown	                       http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb at phy.duke.edu





More information about the Beowulf mailing list