nonnull(常见于编程语境)指“非空”:某个值(尤其是指针/引用/变量)**保证不是 null**。常用于类型系统、静态分析、函数契约(contract)、数据库约束或注解(annotation)中。不同语言/框架里也可能写作 non-null / nonnull / not-null。
/ˌnɒnˈnʌl/
The name field must be nonnull.
name 字段必须为非空。
To prevent crashes, the function checks that the pointer is nonnull before dereferencing it, and the compiler may use that fact to optimize the code.
为避免崩溃,函数在解引用前检查指针非空;编译器也可能利用“非空”这一事实来优化代码。
由前缀 **non-**(“不、非”)+ null(“空值、零值”)构成,字面意思就是“不是空(null)”。在软件工程中,它常被用来表达“该值不允许为空”的约束。