From: mitch grunes on
> Well... my favourite text editor already does what your program do and
> does it live while I'm editing code...

Are you talking about the EMACS editor? I confess I'm not smart enough
to learn it well, and when I tried it it did some things I didn't
expect. I prefer simpler editors that only do predictable things.
Perhaps it is because I never learned much LISP.

I do remember EMACS did something right - you could make it jump to the
beginning or end of the current block - at least if you trust the code
block structure to be correct. When you are fixing that struture in
someone else's code, you don't want your text editor to be so "smart"
it won't let you. (Taking again the example of debugging tens of
thousands of lines of legacy code that doesn't quite work right.)

Pretty printers (auto-indentation, etc.) lose a lot of information,
when you are trying to fix such, and tend to mess up comments,
especially when the author carefully lined up the columns of his/her
comments or code in some sort of table. So I leave the source code
intact, and create seperate diagrams.

I've written a lot of operational code over the last 25 years that ran
various places and was sometimes embedded in ship, air and space-borne
platforms. Sometimes I've had to debug monsters. (Like the pretty lady
said, professionals do what they are paid to do. Though, at the moment,
I am between jobs.) I've found these tools useful. But every programmer
has their own way of working. If you don't like mine, don't use it!

From: Al Balmer on
On 13 Apr 2006 10:03:07 -0700, "mitch grunes" <idlwizard-1(a)yahoo.com>
wrote:

>> Well... my favourite text editor already does what your program do and
>> does it live while I'm editing code...
>
>Are you talking about the EMACS editor?

Many modern program editors do it. Most are easier to learn than emacs
<g>.

> I confess I'm not smart enough
>to learn it well, and when I tried it it did some things I didn't
>expect. I prefer simpler editors that only do predictable things.
>Perhaps it is because I never learned much LISP.
>
>I do remember EMACS did something right - you could make it jump to the
>beginning or end of the current block - at least if you trust the code
>block structure to be correct. When you are fixing that struture in
>someone else's code, you don't want your text editor to be so "smart"
>it won't let you. (Taking again the example of debugging tens of
>thousands of lines of legacy code that doesn't quite work right.)
>
>Pretty printers (auto-indentation, etc.) lose a lot of information,
>when you are trying to fix such,

Could you elaborate on this? What information is lost by reformatting?

> and tend to mess up comments,
>especially when the author carefully lined up the columns of his/her
>comments or code in some sort of table.

That can happen, but some (most?) reformatters can be told to leave
comments alone.

> So I leave the source code
>intact, and create seperate diagrams.
>
>I've written a lot of operational code over the last 25 years that ran
>various places and was sometimes embedded in ship, air and space-borne
>platforms. Sometimes I've had to debug monsters. (Like the pretty lady
>said, professionals do what they are paid to do.

As a professional, I've often considered it my duty to educate those
who tell me what to do ;-)

> Though, at the moment,
>I am between jobs.) I've found these tools useful. But every programmer
>has their own way of working. If you don't like mine, don't use it!

--
Al Balmer
Sun City, AZ
From: kuyper on
Gary L. Scott wrote:
> Edward Gregor wrote:
>
> > slebetman(a)yahoo.com wrote:
....
> >> Well... my favourite text editor already does what your program do and
> >> does it live while I'm editing code. On top of that it also
> >> *highlights* the relevant line when the cursor is on either the opening
> >> or closing brace {}. On top of that it does syntax highlighting. On top
> >> of that it also allows me to fold sections of code to temporarily hide
> >> things I'm not interested in (and remember this is "live" while I'm
> >> editing). And to top it all off it can print, save as RTF save as PDF
> >> and save as HTML the nicely formatted code along with the nice lines.
> >> The only difference is that my editor draws lines based on indentation
> >> while your program auto-indent and draws lines based on braces. But
> >> that's OK, that's what "indent" is for. Oh and yes my editor supports
> >> syntax of more than 40 different languages including C/C++, Tcl,
> >> Fortan, Forth, VB, Perl...
> >>
> >
> > May I ask which editor you are using?
>
> Most decent editors do most of this.

I suppose that's true, for suitable definitions of "most" and "decent".
I've seen editors that do what you say, but they are not as commonplace
in my experience as they seem to be in yours. Would you care to
identify some editors that you consider decent?

From: mitch grunes on
>Pretty printers (auto-indentation, etc.) lose a lot of information...
> and tend to mess up comments,
>especially when the author carefully lined up the columns of his/her
>comments or code in some sort of table.

Could you elaborate on this? What information is lost by reformatting?

Here is an example from a FORTRAN calculator program, which will also
only line up right if you display in a fixed width font like Courier:

! Problems
if((a.eq.'/' .and. y.eq.0).or. ! Divide by 0
& (a.eq.'1/'.and. y.eq.0).or. ! reciprocal of 0
& (a.eq.'^' .and.(y.lt.0 ! Negatives to
negative power
& .or.(x.eq.0.and.y.eq.0))) then ! Zero to zero power

If you only know IDL,
; Problems
if (a eq '/' and y eq 0) or $ ; Divide by 0
(a eq '1/' and y eq 0) or $ ; reciprocal of 0
(a eq '^' and (y lt 0 $ ; Negatives to
negative power
or (x eq 0 and y eq 0)) then begin ; Zero to zero
power

If you only know C,
/* Problems */
if((strcmp(a,'/' )==0 && y==0) || /* Divide by 0 */
(strcmp(a,'1/')==0 && y==0) || /* reciprocal of 0 */
(strcmp(a,'^' )==0 && (y==0 /* Negatives to negative
power */
|| (x==0 && y==0))) { /* Zero to zero power */

No pretty printer is gonna preserve that.

From: Al Balmer on
On 13 Apr 2006 17:20:40 -0700, "mitch grunes" <idlwizard-1(a)yahoo.com>
wrote:

>>Pretty printers (auto-indentation, etc.) lose a lot of information...
>> and tend to mess up comments,
>>especially when the author carefully lined up the columns of his/her
>>comments or code in some sort of table.
>
>Could you elaborate on this? What information is lost by reformatting?
>
>Here is an example from a FORTRAN calculator program, which will also
>only line up right if you display in a fixed width font like Courier:
>
> ! Problems
> if((a.eq.'/' .and. y.eq.0).or. ! Divide by 0
> & (a.eq.'1/'.and. y.eq.0).or. ! reciprocal of 0
> & (a.eq.'^' .and.(y.lt.0 ! Negatives to
>negative power
> & .or.(x.eq.0.and.y.eq.0))) then ! Zero to zero power
>
>If you only know IDL,
> ; Problems
> if (a eq '/' and y eq 0) or $ ; Divide by 0
> (a eq '1/' and y eq 0) or $ ; reciprocal of 0
> (a eq '^' and (y lt 0 $ ; Negatives to
>negative power
> or (x eq 0 and y eq 0)) then begin ; Zero to zero
>power
>
>If you only know C,
> /* Problems */
> if((strcmp(a,'/' )==0 && y==0) || /* Divide by 0 */
> (strcmp(a,'1/')==0 && y==0) || /* reciprocal of 0 */
> (strcmp(a,'^' )==0 && (y==0 /* Negatives to negative
>power */
> || (x==0 && y==0))) { /* Zero to zero power */
>
>No pretty printer is gonna preserve that.

I wouldn't ask a pretty printer to format anything that won't compile.
Count your parentheses and braces. Check the definition of strcmp().

--
Al Balmer
Sun City, AZ