Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Breaking inheritance
Message
From
30/11/2001 17:51:43
 
 
To
30/11/2001 08:33:20
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00587925
Message ID:
00588281
Views:
29
> 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.
Previous
Reply
Map
View

Click here to load this message in the networking platform