How to check if a pointer is in a range of memory (in C).

It's one of the inherent problems with the linear inefficiency of requiring literal comparisons of evaluated values (including null). In a functional approach, the method itself could declare the condition by which it lazily evaluates to true, and then simply iterate in a starting location till the value was found (or not, which is otherwise the worst case scenario for such a method). Knowing that, it could assume it to be false until a collision was detected.

Then that lazy value could be parallelized or partitioned to gain tremendous optimization, both in speed, clarity, correctness, conciseness, and most importantly, ability to remain correct despite changes to other affected elements.

The problem with all of this is that it does demand a lot more overhead, particularly of memory, which conflicts with the notion of efficiency that drives most of these intellectual debates in the first place.

Personally, there are even smarter ways to do it, but why bother going into all that here.

/r/programming Thread Parent Link - blogs.msdn.microsoft.com