On Tue, 2008-03-11 at 23:01 +0100, Ron Blaschke wrote: > Andy Lester wrote: > > > > On Mar 11, 2008, at 2:43 PM, Ron Blaschke wrote: > > > >> It ties pointers to INTVALs, which I guess it shouldn't. > > > > > > As I read the mail, it seems like the only problem we have is in casting > > the pointer to an int to find its truthiness. I'd say use the !!(x) and > > be done with it. The PARROT_ASSERT_POINTER() idea gives me the willies > > because of checking for hardcoded magic values. > > I think you are right. Checking for magic values is useful as a local > modification only, when looking for a specific bug.
I'm confused here. My understanding of the difference between PARROT_ASSERT and the PARROT_ASSERT_POINTER suggestion is that the former checks for truth, and the other would check for lack of obvious insanity. If Parrot has defined other forms of pointer insanity than just NULL, why should there not be a simple test for all of them? The whole point of asserting pointer sanity is to determine that a pointer has been initialized and not corrupted at various points more conducive to debugging, rather than waiting for a (possibly much later) segfault. Having one simple, standard line of code that will do all Parrot-specific insanity tests at once as a free bonus on top of standard NULL testing means it is far more likely to get actually *used*. And this is all hidden behind a macro, so the magic values do not get propagated all over the codebase -- the sanity checking is in one line of macro code. Different locations in the source base won't bitrot and test for different things. And if there were ever more kinds of subtly different insanity defined, then just that one macro could be updated to detect them -- and possibly report on them intelligently. ("Pointer has been garbage collected before use." "Pointer is NULL (perhaps uninitialized)?" "Pointer points into guard area past the end/before the beginning of the allocated memory block." And so on.) Why is any of this bad? (I ask honestly, because I feel like I must be missing something.) -'f