On Thursday, 30 November 2017 at 09:01:20 UTC, Jonathan M Davis wrote:
It's close enough. Instead of segfaulting when the member function is called, it'll segfault when it tries to access one of the member variables or non-final member functions inside the member function. So, there isn't any more need to add null checks for final member functions than there is for non-final member functions.

Err... wait. What if you have a conditional:

    if(input == 0) { do something bad }
    access field

Seems like you would be better off by injecting:

   assert this not null

at the beginning of all final methods and remove the assertion if all paths will lead to a field access before something bad can happen.

Adding checks and then only remove them if they provably have no consequence tend to be the safer approach.

Reply via email to