On 2006-06-23, Akim Demaille akim@lrde.epita.fr wrote:
"SIGOURE" == SIGOURE Benoit sigoure.benoit@lrde.epita.fr writes:
; (?i, ?decimals) // i="42", decimals="000000"
; ?(i, decimals) // i="42", decimals="000000"
Mere optimization, or more mandatory?
It's a simple optimization.
The previous line was compiled in C using two nested functions. (s1, s2) is a congruence where s1 is a strategy applied to the first element of the couple, and s2 to the second element. Here, s1 and s2 are provided "inline". This is translated in C using two nested functions:
ATerm SimplifyDoubles_0_0(..., ATerm t) { auto ATerm n_0(..., ATerm t); // prototype of the nested function for s1 auto ATerm o_0(..., ATerm t); // prototype of the nested function for s2
ATerm n_0(..., ATerm t) { // match and return current term } ATerm o_0(..., ATerm t) { // match and return current term } // call n_0 and o_0 }
whereas now it's a simple matter of matching both elements of the tuple (no nested functions etc)
By the way, nested functions are a GNU extension and the auto qualifier is mandatory to prototype these nested functions. See http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Nested-Functions.html#Nested-Fun...
"A nested function always has no linkage. Declaring one with extern or static is erroneous. If you need to declare the nested function before its definition, use auto (which is otherwise meaningless for function declarations)."