[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

snmpconf Recommendations for Policy Language Implementation




I would like to make some recommendations for the
policy language.

1.  Nested comments should be allowed.

2.  Our implementation of sprintf(), unlike the C
    version, should make sure that the number of
    format specifiers in the format string matches
    the number of corresponding arguments.  Our version
    of sprintf(), unlike the C version (which is call
    by value), should be call by reference (to match the rest of
    the policy language). 
    
3.  The order of evaluation of arguments to function calls 
    should be right-to-left.  This is unspecified in C.
    Right-to-left matches the gcc and Turbo C implementations.
    The following test program demonstrates how different
    compilers evaluate arguments.
    
    Ray Byler    

/* 
    We are supposed to implement sprintf() for the policy
    language as defined in C.  The problem is that 
    C says "the order of evaluation
    of arguments is unspecified".  This can produce some
    peculiar results.  The following test program demonstates
    this for printf (sprintf is the same).  

*/   

#include <stdio.h>

/* Since variables in the policy language are all in
 * the same scope they will all be globals.
 */
 
int a = 7;

main(){

     printf("%d %d %d %d %d %d %d\n", a++, a++, a++, a, a--, a--, a--);
     printf("final: %d\n\n", a);

     printf("%d %d %d\n", a++, a++, a++);
     printf("final: %d\n\n", a);

}


/*
    gcc and Turbo C evaluate arguments from right to left.

6 5 4 4 5 6 7
final: 7

9 8 7
final: 10

    Microcrap's Visual C++ defers action until after the function call is complete.

7 7 7 7 7 7 7
final: 7

7 7 7
final: 10


    HP's cc evaluates arguments from left to right.
    
7 8 9 10 10 9 8
final: 7

7 8 9
final: 10


*/