Re: Free source code diagramming programs [message #48344 is a reply to message #48304] |
Thu, 13 April 2006 17:43   |
Al Balmer
Messages: 3 Registered: April 2006
|
Junior Member |
|
|
On 13 Apr 2006 17:20:40 -0700, "mitch grunes" <idlwizard-1@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
|
|
|