[AccessD] Can a function return an object?

Stuart McLachlan stuart at lexacorp.com.pg
Sun Mar 26 16:57:15 CDT 2023


You are conflating ideas and over complicating thiings:

Oxford dictionary:

dereference something to use a piece of data to discover where another piece 
of data is held. 

Wiktionary:
dereference

Wiktionary 
https://en.wiktionary.org > wiki > dereference


(programming) To access the value or object located in a memory location stored in 
a pointer or another value interpreted as such;

The concepts of "reference count" and "garbage collection " is what you are thinking about 
and it is something else entirely

"deferencing" and " acquiring and releasing  references"  are two entirely different conepts.

Reference counting is necessary so that shared memory used by  objects is released when it 
is no longer needed.  

Fundanetally, ALL pointers just point to a memory location.  How your application handles 
what is at that location(and following locations) is up to you.  It's just a string of bytes.

If it's a pointer to a function or object, it's generall called a Code Pointer  and you would  
CALL the code at that location (that's the basis of sub-classing (which VBA can't do) and 
Callbacks.

Here's a couple of examples of using a Code Pointer:

WinHTTPStatusCallback is the name of a function which a WInHTTPRequest() can use to 
supply information about the progress of the request.

fStatus = WinHttpSetStatusCallback(hRequestHandle,CODEPTR(WinHTTPStatusCallaback, 
_ %WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS,BYVAL %NULLl)


or subclassing an edit control (textbox)

FUNCTION EditSubCLassProc(.......
...
oldProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))       .

-- 
Stuart

On 26 Mar 2023 at 7:25, John Colby wrote:

> The interpreter keeps track of how many objects are referencing a
> given object.  It does this for garbage collection purposes at the
> very least.
...
> So it truly isn't as simple as 'here is a pointer to a memory
> location', have fun with it.  the system has to handle this reference
> count thingie.
> 
> Similarly a pointer or reference points to an object.  The object is
> different depending on what is being referenced.  The footprint in
> memory is going to be different for a string as opposed to a form as
> opposed to a recordset.  How the object is used, what you can do with
> it, An object such as a class can have entire sections of code as well
> as data.  In some languages an object like a string also has code
> which can do things like upper or lower or proper case it etc.
> 
> So just handing around pointers to objects is problematic.  I assume
> (out of extreme ignorance of the subject) that every object has a
> descriptor which tells the caller what it is and how to use said
> object.  So the process of 'getting back' or using any object is going
> to be an entire process.  I simply assumed this process is what
> 'dereferencing' means.
> 
> I have never found it necessary to understand the details of
> dereferencing.  I just have a high level concept of 'it must do this
> kind of thing' to use the object referenced.
> 



More information about the AccessD mailing list