Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
#DEFINE - Why?
Message
De
30/03/2008 21:37:45
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
30/03/2008 19:58:17
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01306848
Message ID:
01306856
Vues:
12
See my reply to Nadya.

>>What is the simplest explanation as to why these are needed? Why not just set regular variable values? So what if they are constant and don't change?
>
>One reason is that a variable needs additional overhead.
>
>
>x = 5
>
>* or:
>
>#define SOMENUMBER 5
>x = SOMENUMBER
>
>
>are both equivalent; in this case, the number is first assigned directly.
>
>
>local lnSomeNumber
>lnSomeNumber = 5
>...
>x = lnSomeNumber
>
>
>In this second example, not only does the variable lnSomeNumber need extra space (a slot in the variable table, I think, although I am not quite clear about all the technical details), but every time it is accessed, the variable must be looked up.
>
>Other languages work different in this respect; so there is not so much difference between "constants" and "variables", but for safety, a variable may be declared as unchangable.
>
>By the way, that should be another reason to use constants. A variable can be assigned any value at any moment. A constant is supposed to be treated as constant. Oh well, you could re - #DEFINE in another part of the program. Sigh.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform