Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Default LOCAL variable declaration
Message
De
29/10/2001 14:38:14
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
29/10/2001 12:57:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00574603
Message ID:
00574673
Vues:
27
>>So how DO variables get declared by default?

>The default declaration is not exactly one of the other declarations: public, private, or local. It is most similar to private, in that the variable is visible in lower-level functions (called from the function where the variable is assigned), and will loose scope in higher-level functions (that is, as soon as the function where it is assigned RETURNs). However, PRIVATE will hide higher-level variables; the default declaration will not.

If there's a higher-level variable of the same name, no default declaration takes place at all. The higher level variable is just used as is and no new variable is created.

Still, it's good that you pointed this out, because if someone relies on such variables being private by default in the current method, a variable with the same name may also be created by default as private in a method calling it, and this is sure to cause trouble and waste of time. Errors like this are not that hard to catch, they just take time. I'd go for local whenever there's no reason to do otherwise. Actually, local should be the default, but when they were introduced in VFP3, the privates were already set as default in previous versions, and there was megabytes of code out there which would break if this was changed, so it remained as it is. Also, introducing a Set DefaultDeclaration To Private/Local/Public would create chaos and generally unreadable code, so that wasn't an option either.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform