开发者

What's the right phrase for a special return value that indicates failure?

With methods such as java.lang.String.indexOf, which finds the position of the first occurrence of a characters, the return value is a "nonsensical" value such as -1 when the search fails. What is the correct term for such a special value? I find myself wanting to call them "sentinel values" but that's not quite right.

What I want to capture is the idea that it is an instance of the return type but a special value that can easily be dist开发者_高级运维inguished (e.g. by being less than zero or equal to null).

Any thoughts? Thanks!


"Failure value" is self-explanatory, and has at least some prior usage.


AFAIK it's called an error code.


I like to think of it as an example of in-band signaling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜