Thread overview
[Issue 5416] New: null should have a type of its own
Jan 06, 2011
Simen Kjaeraas
Oct 07, 2011
Benjamin Thaut
Oct 27, 2011
Walter Bright
Oct 27, 2011
timon.gehr@gmx.ch
Oct 27, 2011
Kenji Hara
Nov 25, 2011
Walter Bright
January 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416

           Summary: null should have a type of its own
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: simen.kjaras@gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-01-05 16:30:53 PST ---
Currently, it is impossible to special-case comparisons with null. If instead null had its own type, one could allow direct comparisons between user-defined types and null, instead of supporting comparison with any and all void*s.

For structs, such a comparison function could then be used for both 'foo == null' and 'foo is null'. For classes, neither likely makes sense.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416


Benjamin Thaut <code@benjamin-thaut.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@benjamin-thaut.de


--- Comment #1 from Benjamin Thaut <code@benjamin-thaut.de> 2011-10-07 09:08:52 PDT ---
Also if you pass null to a template it completely looses its implict conversion abilites. See following example.

void foo(Object o){
}

void fooHelper(T)(T o){
  foo(o);
}

void main(string[] args){
  fooHelper(null); //can not implicitly convert void* to Object
}

This also stops std.conv.emplace to work correctly with constructors you want to pass null to.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416



--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-10-27 01:12:57 PDT ---
n.g. discussion: http://www.digitalmars.com/d/archives/digitalmars/D/Own_type_for_null_147608.html

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch


--- Comment #3 from timon.gehr@gmx.ch 2011-10-27 02:07:54 PDT ---
(In reply to comment #1)
> Also if you pass null to a template it completely looses its implict conversion abilites. See following example.
> 
> void foo(Object o){
> }
> 
> void fooHelper(T)(T o){
>   foo(o);
> }
> 
> void main(string[] args){
>   fooHelper(null); //can not implicitly convert void* to Object
> }
> 
> This also stops std.conv.emplace to work correctly with constructors you want to pass null to.

This is still true if 'Object' is replaced by Object[], 'null' is replaced by '[]' and 'void*' by 'void[]'. Therefore, '[]' needs an own type too.

(I think it is the same issue, or should I file a separate bug for it?)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-27 05:05:57 PDT ---
https://github.com/D-Programming-Language/dmd/pull/476

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5416


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-11-25 00:29:16 PST ---
https://github.com/D-Programming-Language/dmd/commit/31a3e406938cef17c8c6354ac5de70ad07707027

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------