Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find a flaw in the logic
Message
De
13/01/2006 11:04:56
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
13/01/2006 09:27:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01086027
Message ID:
01086551
Vues:
17
>>>>>You are right. However, I'm of opinion that you are actually breaking a 'standard rule' here. You are at risk of changing the value of a variable in the calling program. The code should be something like:
>>>>>
>>>>>
lparameters tlEnabled, toObject
>>>>>
>>>>>local loObjectX    && you're already using loObject for another purpose
>>>>>
>>>>>if vartype( m.toObject ) <> "O"
>>>>>	loObjectX = this
>>>>>else
>>>>>	loObjectX = m.toObject
>>>>>endif
>>>>
>>>>No risk at all since I'm using lparameters and not passing variable by reference.
>>>
>>>Ah, but, as far as I know, objects are always passed by reference, because the object type variables are references to actual objects. So if you pass an object by value, you do get a new variable, which still refers to the same object.
>>
>>
>>You're absolutely right. That again proves that Peter is wrong <g>, since two people can only be right at the same time in Hershelle Ostropoller's stories. <g>
>
>Peter is wrong? <g>

We're both right, it's only that you were pointing out something else.

So yes, your example shows that an object variable, when passed by reference, may be pointing to another object or may even become a variable of any other type.

My point was that regardless of how you pass the object variable, it still doesn't create a copy of an object, and that whatever you do to the its PEMs, they do affect the object as if the object was passed by reference, even if you pass it by value.

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