Oxygene: not nullable method parameters

Hello,
When a parameter of a method has the not nullable modifier, the compiler adds code to check if the paremeter is null and raises an ArgumentNullException if needed.

This is a good thing, but there are two problems with this:

  1. This is not documented.
    I found it when looking for the code of a method. The problem with features not documented is that we cannot trust them: if they are documented, we’re sure that it must work this way and will not change in the future or, if they change, the change will be documented (at least in an ideal world).

  2. Duplicate code.
    As this behavior is not documented, developers (me included) add manually the code to check whether the parameter is null… and the check is made twice!
    A solution to this would be to add a warning. For example, the compiler could use the warning that says expressions always evaluate to false when checking whether a nullable value is assigned or not.

3 Likes