![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
SET UDFPARMS does not cover the case of a parameter being an object. I can not think of where else to check. (@ does not do it G>.) I need to pass an object to another object. In the processing that the second object does, the first object's state will normally change. The object pointed to by the parameter will not. I realised that I am not sure how to do this. (The first object is a data collector. I can not instantiate the first object in the second object as the first object's lifetime may have to be more than one second object lifetime.) Illustrative snippets: firstobjectref=createobject("firstobject" ... ) secondobjectref=createobject("secondobject",firsto bjectref) secondobjectref.somesecondmethod(...) define class secondobject as ... ... procedure init lparameters ... firstobj ... this.firstobj=firstobj ... endproc procedure somesecondmethod this.firstobj.somefirstmethod(...) but not this.firstobj=... Is the createobject() correct, or should it be ... @firstobjectref ... ? How does the answer change if the object pointed to by the parameter could change (and it is to be passed back to the caller)? Any other gotchas to watch for? Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
You can't inn fact pass an object by value, Objects are always handled via a reference. |
#5
| |||
| |||
|
|
Objects are always handled via a reference. Such a reference could be passed by ref or by value. |
#6
| |||
| |||
|
|
I see the point, okay. But what you do to the parameter holding the passed in object is rather unusual. As you showed yourself the property of loObj is modified whatsoever, and I think that is more important to Gene or anyone interested. And you might never want to pass in object references by reference (with @), for the safety to have them intact after the call, only modified, but not destroyed or replaced. |
#7
| |||
| |||
|
|
A use case for "by ref" object parameters might be a factory routine which returns one or more objects via parameter. |
#8
| |||
| |||
|
|
Hey Gene. another approach would be to have the object live in an object hierarchy. I use a top level oApp object, and attach other objects to it. The scope then is global to everything. |
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |