undefined variables (was Top 10 Language Constructs (Modula-2)) 
Author Message
 undefined variables (was Top 10 Language Constructs (Modula-2))

just to followup on the theme of Assert's which Andreas Borchert mentions.
The m2f compiler takes the same approach with Assert's (similar magnitude
as well). A few years ago I became paranoid about the effect on performance
of these statements - and so I profiled the compiler when compiling
small, medium, large modules. The Assert procedure calls accounted for
less than 1% of the execution time. The m{*filter*}of the story liberally
scatter Asserts throughout.

Quote:
Martin Brown writes:
> But only in the debugging environment, and there were some static analysers about
> that can make quite a lot of headway with fault finding access to undefined
> variables etc in Modula code. I thought XDS did one, but I couldn't find their old
> web page for it any more.

Stuart Lewis and I did some work on this a few years ago
(URL: floppsie.comp.glam.ac.uk://MyPapers/paper6/6.html). Granted, static
analysis is limited, nevertheless it can show up some surprising oversights.
One real example we came across was:

PROCEDURE IsItemOnList (p, q: PtrToNode) : BOOLEAN ;
BEGIN
   WHILE p#NIL DO    (* line 24 *)
      IF p=q
      THEN
         WriteString('found item') ;
         WriteLn
      ELSE
         p := p^.Next
      END
   END ;
   RETURN( FALSE )
END IsItemOnList ;

[the programmer had omitted RETURN( TRUE ) from line 28]

and the compiler reported:

foo.mod:24:warning it is very likely (although not absolutely certain) that the top of an infinite loop is here
foo.mod:29:warning and the bottom of the infinite loop is ends here or alternatively a component of this loop is never executed

Gaius

---



Fri, 10 Jan 2003 03:00:00 GMT  
 undefined variables (was Top 10 Language Constructs (Modula-2))
Gaius, out of curiousity, can m2f be compiled to run under Win-32 using
Cygnus? If so does it stand any chance of generating .exe files?

-- Mark Morgan Lloyd

--
-- [Opinions above are the author's, not those of his employers or
colleagues]



Thu, 16 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Top 10 Language Constructs (Smalltalk)

2. Top 10 Language Constructs (Forth)

3. Top 10 Language Constructs (Modula2)

4. Top 10 Language Constructs (Oberon)

5. Top 10 Language Constructs (Eiffel)

6. Top 10 Language Constructs (Scheme)

7. Top 10 Language Constructs (Ada)

8. Top 10 Language Constructs (Cobol)

9. Top 10 Language Constructs (Fortran)

10. Top 10 Language Constructs (Phyton)

11. Top 10 Language Constructs (Prolog)

12. Top 10 Language Constructs (Lisp)

 

 
Powered by phpBB® Forum Software