Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ARGG! VFP send my objects by reference, no by value!!!!
Message
From
07/03/2000 23:43:34
 
 
To
07/03/2000 22:24:15
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00342323
Message ID:
00343124
Views:
27
>Ed,
>
>>because objects can contain objects. You also have the issue of things like >private data sessions to make life -really- messy.
>
>Yeah that sounds like it could screw things up. :)
>
>While we are on the subject of pointers to pointers, and copies of references, what would one use this level of indirection for?
>
>For example-
>
>VFP:
>
>someFunc(@oObj)
>

This one's easy - I want to populate an object ref, substitute another object for an existing object referenced in the caller, or completely dereference an object that was passed to a function or method if I choose to assign a new value to the original object reference. Unlike pass by value, this doesn't bump the object's reference counter, since no new reference is being created.

>C/C++:
>
>int someFunc(void **ppint);
>

Typically, a pointer to an array or list of pointers; lots of uses in entrypoint lists and function tables, or in COM, a pointer into a vtable. You might want to take a read of:

The COM Programmer's Cookbook
Crispin Goswell
Microsoft Office Product Unit

Spring 1995
Revised: September 13, 1995

in the MSDN library and look at the QueryInterface description - the construct is used to pass the vtable back through IUnknown, as one example.

The following is cut from the topic on indirection and address-of in the VC++ docs:
Indirection and Address-of Operators
The indirection operator (*) accesses a value indirectly, through a pointer. The operand must be a pointer value. The result of the operation is the value addressed by the operand; that is, the value at the address to which its operand points. The type of the result is the type that the operand addresses.

If the operand points to a function, the result is a function designator. If it points to a storage location, the result is an l-value designating the storage location.

If the pointer value is invalid, the result is undefined. The following list includes some of the most common conditions that invalidate a pointer value.

The pointer is a null pointer.

The pointer specifies the address of a local item that is not visible at the time of the reference.

The pointer specifies an address that is inappropriately aligned for the type of the object pointed to.

The pointer specifies an address not used by the executing program.

The address-of operator (&) gives the address of its operand. The operand of the address-of operator can be either a function designator or an l-value that designates an object that is not a bit field and is not declared with the register storage-class specifier.

The result of the address operation is a pointer to the operand. The type addressed by the pointer is the type of the operand.

The address-of operator can only be applied to variables with fundamental, structure, or union types that are declared at the file-scope level, or to subscripted array references. In these expressions, a constant expression that does not include the address-of operator can be added to or subtracted from the address expression.



>And I have seen it (in COM literature for example) cast like:
>
>x = someFunc((void**) *&pvar);
>
>What is the reason for this?
>

That's a bizarre recast of a pointer to a pointer...I don't recognize the construct, since *& resolves to self. I'd more expect a construct like (void**) &ptr->, which is used pretty frequently instantiating objects with CoCreateInstance() to receive the interface pointer. I'd expect to receive an interface pointer if I saw it.


>TIA,
>Bill
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform