Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Breaking inheritance
Message
De
30/11/2001 17:51:43
 
 
À
30/11/2001 08:33:20
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00587925
Message ID:
00588281
Vues:
30
> I just found out one more way to get into trouble: passing a parameter to DoDefault(), and forgetting that the parameter is an array.
>lparameters taMyArray, tnPar2, tcPar3
>DoDefault(taMyArray, tnPar2, tcPar3)
>* Gives error message: the passed parameter is no longer an array.
If you hook into a function call then you should always forward by reference. The actual value vs. reference business is between your caller - who uses @ or (...) as they see fit - and the original callee (i.e. the function you are forwarding to) who will modify passed parameters or not, according to the interface specification. This is the only way to preserve semantics without knowing specifics and it automatically protects you against changes in the caller or in the called function. An added bonus is that no unnecessary copying of parameters is done (this can have a substantial impact on processing time if there is a substantial number of calls involved in your processing).

Note: there are some exceptions to this rule (like when you call down to the bare metal - system functions or functions in DLLs/FLLs) but these do not apply to overriding object methods.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform