Forum > General

[CLOSED] Absolute

<< < (2/3) > >>

pcurtis:
So the answer becomes similar, but don't use.

440bx:

--- Quote from: Warfley on December 04, 2021, 03:39:51 pm ---IMHO there is absolutely no case where absolute is a good idea. If Access to the same memory is required, variant records and/or (pointer) casting is always preferential, as it archives the same effect, while 1. being more verbose about what is actually happening here and 2. performs error checking

--- End quote ---
It isn't my intention to be argumentative but, there are occasions where "absolute" is a better choice than typecasting.  Some of the examples that come to mind include:

1. Some Window message apply a structure to wParam, lParam or both.  It works as documentation to absolute the structure on top of the parameter and, if either parameter is used often in the processing of the message, there is a lot less clutter than having to typecast every use.

2. Similar to (1) above.  When creating a thread, it is common to pass a parameter to the thread, usually as an untyped pointer.  The thread function receives it as an untyped pointer and, IMO, it is cleaner and much simpler to "absolute" the correct pointer type of top of the thread parameter.

3. Similar to (2) above.  When using external sort routines, those routines specify an untyped pointer.  The implementation of the compare function receives that untyped pointer and the simplest and, IMO, most informational is to "absolute" the correct pointer type on top of compare function parameters.

Those are three instance I can think of off the top my head as I type this and, and I know there are more than that.

All that said, I completely agree that someone who doesn't understand what absolute does would be very wise to stay away from it. 

Warfley:
About 2 and 3, what I like to do is to simply define them with the "correct" pointer type and typecast the function pointer when providing the callback parameter

engkin:

--- Quote from: Warfley on December 04, 2021, 06:00:44 pm ---About 2 and 3, what I like to do is to simply define them with the "correct" pointer type and typecast the function pointer when providing the callback parameter

--- End quote ---

What makes this typecast better than using absolute?

engkin:

--- Quote from: 440bx on December 04, 2021, 04:03:51 pm ---All that said, I completely agree that someone who doesn't understand what absolute does would be very wise to stay away from it.

--- End quote ---

Wouldn't it be better to learn what absolute does and use it appropriately?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version