Information générale
Catégorie:
Codage, syntaxe et commandes
>Hi Albert,
>>>
>>
>>What is confusing? It #defines in foxpro work just like they do in all of the other languages that use them (with the exception of case insensitivity). It is just compile time macro expansion. I would not worry about the behavior changing, it is standard now.
>
>First, AFAIK no other language evaluates a compile time constant at run time. That in and of itself leads to some confusion. Once evaluated at compile time, it is what is says, a constant and cannot be changed. In this case the value can be changed, which, by definition, makes it a variable. Second, one of the benefits of using compile time constants is that the reference to it doesn't have to be evaluated at run time, leading to improved performance. That's not the case here. Anytime a native function call is used in assigning a compile time constant, it is re-revaluated at run time. It doesn't matter if the function always returns the same value (i.e. REPLICATE("A", 5)) or not (i.e. SYS(5) + SYS(2003)). It's re-evaluated.
The behavior that you describe is exactly what I expect, it works just the same as C and C++. C/C++ functions are not evaluated at compiletime either. A #define is just code to be pasted into the source durring the preprocessor phase. Name for me a language that uses #define and evaluates the macro expressions at compiletime. Other development environments may have the ability to evalute expressions at compiletime, but I am not aware of any that uses the #define syntax for this purpose.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement