Current Definition of a handle?

I am a self taught coder and I just came across something on line that made me think the definition of handle I’ve always used may be wrong… or maybe the definition has changed over the years as OSes got more complex.

Back in the dark ages I thought I learned that a handle is just basically a pointer to a pointer… or to put it another way, a handle is a variable that holds th address of a static location in memory which has the current address of the underlying data.

It’s purpose is to allow relocation of the underlying data representing the object to be moved around in memory, but its current address would always be available though the handle so it could always be accessed no matter when the underlying data is moved.

Now I am reading handles are all about opaque data types… But I thought I remembered dereferencing a handle to get a pointer that I used to get at the underlying data way back when…

While a handle could be used to hide the details of an underlying data structure, it would not need to do that to perform what I thought was it’s main function of just providing way to get at data the OS might be moving around while it is managing memory.

Am I mistaken?

  • karen

Hi @Karen Atkocius

If you’re mistaken… I’m too. As far as I know, a handler is an indirection to a memory pointer. :slight_smile:

It is not always a pointer.

It can be also an index in some lookup table like Windows window handle.

Relationship Between a C++ Window Object and an HWND

[quote=467376:@Christian Schmitz]It is not always a pointer.
It can be also an index in some lookup table like Windows window handle.[/quote]

Agreed. C/C++ (Xojo Declares) handles are usually numbers to a place in memory. Could the number be to another pointer -sure. Could the number be to an address of data - yep. It could also be a place in memory that references other places in memory - and can go easily to 5-sub-levels of a pointers - pointers - pointers -pointers - point to data - yep.

@Christian Schmitz yep, sure! Just to simplify… the main point: indirection.

The main point: identification. Indirection is an implementation detail.

Thanks for the discussion…seems things have gotten more complicated over the years!

When i leaned about handles and pointers and such, it was not with any of the current operating systems… It was coding on an 8 bit Atari 800 computer in a proprietary language I bought for it (not BASIC)…

While i liked the speed , I realized i preferred not to code at that level if I did not have to (which is one reason I started using REALBasic), so I never delved deeply into it with the current OSes and have just relied on the basic understanding of those concepts that I picked up in the early 80s.

  • Karen