gregoryyoung / nothing

Replacement of the System.Void type
The Unlicense
57 stars 11 forks source link

Bug: this type supports the "null" value #2

Open dsyme opened 9 years ago

dsyme commented 9 years ago

The "Nothing" type supports the "null" value in addition to the "Instance" value. That's a bug. Please update your programming language to make sure that it doesn't permit null values of this type under normal use. Do not close this issue until you have successfully done this.

pavel-khritonenko commented 9 years ago

It should be struct instead of class

tpetricek commented 9 years ago

Right! As things stand, having two possible values, the so-called type "nothing" is actually equivalent to "Boolean"!

Daniel15 commented 9 years ago
public class AwesomeBoolean
{
    public Nothing True { get { return Nothing.Instance; } }
    public Nothing False { get { return null; } }
}
gregoryyoung commented 9 years ago

LOL!

On Sun, Mar 8, 2015 at 8:57 AM, Daniel Lo Nigro notifications@github.com wrote:

public class AwesomeBoolean { public Nothing True { get { return Nothing.Instance(); } } public Nothing False { get { return null; } } }

— Reply to this email directly or view it on GitHub https://github.com/gregoryyoung/nothing/issues/2#issuecomment-77736278.

Studying for the Turing test

dsyme commented 9 years ago

The proposed fix (also the one adding "sealed") means we can no longer inherit from Nothing.

It seems clear that each and every thing "is a" nothing - maximum flexibility requires an open universe of possibilities (see also https://github.com/gregoryyoung/nothing/issues/24#issuecomment-77916676).

Further, inheriting a hidden something from Nothing is a well known tax avoidance strategy in some jurisdictions.