Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why can't I pass object property by reference
Message
 
 
À
01/04/2002 21:47:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00639771
Message ID:
00639787
Vues:
17
I don't think you can do that in any OOP language because it would breake object encapsulation. The property doesn't exists by itselff, it belongs to the object. It means you can access it only thru the object. If you could pass property by reference than you would be able to "disconnect" property from the object because you would be able to reference it directly. Can you call it a property after that?

>Sergey,
>
>Thanks!!
>
>Is there a reason for this limitation. In other words is there a design issue that would make it wrong to allow for this. How do other languages handle it? Why the distinction between allowing the object itself to be passed by reference, but not an object property?
>
>Where can I find some good documentation on these behaviors?
>
>>Visual FoxPro always passes object properties by value. Object properties cannot be passed by reference.
>>
>>>I am attempting to write code to allow one class use another classes' objects.
>>>
>>>I have a class bctblhandler that needs to use the methods of another class, tblhandler. bctblhandler has a property, tblhandlerIVN, which stands for for tblhandler Instance Var Name.
>>>
>>>so I can say:
>>>
>>>obctblhandler.tblhandlerIVN=otblhandler
>>>
>>>But I wanted to write a procedure that would allow me to cross reference the two generically. So I wrote:
>>>
>>>XrefClass(@obctblhandler.tblhandlerIVN,otblhandler)
>>>
>>>procedure xrefclass
>>>parameters toIVN, tobject
>>>toIVN=tobject
>>>
>>>
>>>endproc
>>>
>>>but this didn't work. When calling it I get, alias obctblhandler does not exist.
>>>
>>>so I had to write:
>>>
>>>XrefClass('obctblhandler.tblhandlerIVN',otblhandler)
>>>
>>>procedure xrefclass
>>>parameters toIVN, tobject
>>>store tobject to &toIVN
>>>endproc
>>>
>>>instead.
>>>
>>>
>>>What am I doing wrong? BTW, tblhandlerIVN is not defined as protected or hidden.
>>>
>>>TIA
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform