Language Design, Syntax, and Reliable Programming



Language Design



With and Use



Comments



Problems with Block Comments

  1. Consider this:
        /* x = 3;           * /
        y = 4;         
        /* z = 5; */
        
  2. Did you catch the error above? Now consider this:
        /* Startup
        x = 3;     
        /* Reset count  */
        count = 2 * x;
        
  3. And this:
        /* x = 3;      
        y = 4;         
        /* Come back and think about z's value
         * z = 5; 
         */
        
  4. This C code ...
        int i = 98;
        int * p = & i;  /* pointer p points to i */
        i = i / *p;         
        i = /* say something about the expression here */
        -4;
        printf("%d\n", i); /* result is -4 */
        
  5. ... gives different results from this C code:
        int i = 98;
        int * p = & i; 
        i = i /*p;          -- Starts a comment!!!
        i = /* say something about the expression here */
        -4;
        printf("%d\n", i); /* result is 94 */
        
  6. Different results in C and C++ (from Stroustrup):
        int b = a//* divide by 4 */4;
        -a;
        
  7. Is nesting allowed?

  8. You don't need to know C to see that lots of problems can arise!
  9. Some examples from Van Tassel, 2004 web paper


Range Constraints and Subtypes



New Numeric Types



Pre and Post Conditions



Numeric Literals



Ada Literals



For Loop Statement



Case Statement - Multiway Selection



Some Java Code



Function vs Procedure



What About This?



Keyword Parameters



Enumerated Types



Don't Do This