digitalmars.D - Own type for null?
- Benjamin Thaut (15/15) Oct 25 2011 I recently tried to replace the deprecated overloading of new and delete...
- Gor Gyolchanyan (5/20) Oct 26 2011 I agree. Null is a very common special-case value and overloading may
- deadalnix (2/6) Oct 26 2011 +1 for me ! And +1 for non nullable types.
- Timon Gehr (3/15) Oct 26 2011 ++vote.
- Gor Gyolchanyan (4/23) Oct 26 2011 Yes! Empty array is also a special-case value, which can be
- Benjamin Thaut (5/24) Oct 26 2011 Do you have an example where a own type for [] would be usefull?
- Gor Gyolchanyan (3/31) Oct 26 2011 Functions, overladed on different types of arrays will always fail
- Timon Gehr (13/36) Oct 26 2011 It is the same rationale as the one for null
- kenji hara (4/28) Oct 27 2011 +1
- kenji hara (4/34) Oct 27 2011 https://github.com/D-Programming-Language/dmd/pull/476
- Timon Gehr (3/6) Oct 27 2011 Great! Thank you. I hope that is merged soon. What do you think about
- Benjamin Thaut (5/13) Oct 27 2011 Sounds good to me.
I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge? -- Kind Regards Benjamin Thaut
Oct 25 2011
I agree. Null is a very common special-case value and overloading may be necessary based on that special-case value. Currently doing so means accepting any kind of typeless pointer (which is certainly not desirable). On Wed, Oct 26, 2011 at 9:49 AM, Benjamin Thaut <code benjamin-thaut.de> wrote:I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge? -- Kind Regards Benjamin Thaut
Oct 26 2011
Le 26/10/2011 09:20, Gor Gyolchanyan a écrit :I agree. Null is a very common special-case value and overloading may be necessary based on that special-case value. Currently doing so means accepting any kind of typeless pointer (which is certainly not desirable).+1 for me ! And +1 for non nullable types.
Oct 26 2011
On 10/26/2011 07:49 AM, Benjamin Thaut wrote:I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge?++vote. We also need an own type for the empty array literal '[]' btw.
Oct 26 2011
Yes! Empty array is also a special-case value, which can be interpreted in a special way, which is completely different from any other array. On Wed, Oct 26, 2011 at 12:56 PM, Timon Gehr <timon.gehr gmx.ch> wrote:On 10/26/2011 07:49 AM, Benjamin Thaut wrote:I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge?++vote. We also need an own type for the empty array literal '[]' btw.
Oct 26 2011
Am 26.10.2011 10:56, schrieb Timon Gehr:On 10/26/2011 07:49 AM, Benjamin Thaut wrote:Do you have an example where a own type for [] would be usefull? -- Kind Regards Benjamin ThautI recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge?++vote. We also need an own type for the empty array literal '[]' btw.
Oct 26 2011
Functions, overladed on different types of arrays will always fail with empty arrays unless empty arrays have their own type. On Wed, Oct 26, 2011 at 7:55 PM, Benjamin Thaut <code benjamin-thaut.de> wrote:Am 26.10.2011 10:56, schrieb Timon Gehr:On 10/26/2011 07:49 AM, Benjamin Thaut wrote:Do you have an example where a own type for [] would be usefull? -- Kind Regards Benjamin ThautI recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge?++vote. We also need an own type for the empty array literal '[]' btw.
Oct 26 2011
On 10/26/2011 05:55 PM, Benjamin Thaut wrote:Am 26.10.2011 10:56, schrieb Timon Gehr:It is the same rationale as the one for null Eg: class Class{ this(int,string,double[]) {} } auto New(T,A...)(A args) { return new T(args); } void main(){ auto a = new Class(1,"hi",[]); // fine auto b = New!Class(1,"hi",[]); // would require an own type }On 10/26/2011 07:49 AM, Benjamin Thaut wrote:Do you have an example where a own type for [] would be usefull?I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge?++vote. We also need an own type for the empty array literal '[]' btw.
Oct 26 2011
+1 I think 5899 is related issue. Kenji Hara 2011/10/26 Gor Gyolchanyan <gor.f.gyolchanyan gmail.com>:I agree. Null is a very common special-case value and overloading may be necessary based on that special-case value. Currently doing so means accepting any kind of typeless pointer (which is certainly not desirable). On Wed, Oct 26, 2011 at 9:49 AM, Benjamin Thaut <code benjamin-thaut.de> wrote:I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge? -- Kind Regards Benjamin Thaut
Oct 27 2011
https://github.com/D-Programming-Language/dmd/pull/476 The pull request implementing that enhancement. Kenji Hara 2011/10/27 kenji hara <k.hara.pg gmail.com>:+1 I think 5899 is related issue. Kenji Hara 2011/10/26 Gor Gyolchanyan <gor.f.gyolchanyan gmail.com>:I agree. Null is a very common special-case value and overloading may be necessary based on that special-case value. Currently doing so means accepting any kind of typeless pointer (which is certainly not desirable). On Wed, Oct 26, 2011 at 9:49 AM, Benjamin Thaut <code benjamin-thaut.de> wrote:I recently tried to replace the deprecated overloading of new and delete and came across a serious issue. You can not use std.conv.emplace with null. If you pass null to it, null loses it's implicit casting cabablities and just becomes a void*. This issue pretty much exists with every template. As soon as you pass null to a template (compile time) information gets lost. Besides fixing std.conv.emplace it could be really handy to be able to check for a null-type at compile time for example with non-nullable types. There is already a enhancement reqeust in bugzilla since January but it didn't get much attention yet: http://d.puremagic.com/issues/show_bug.cgi?id=5416 Would this be a worthwile improvement for the langauge? -- Kind Regards Benjamin Thaut
Oct 27 2011
On 10/27/2011 02:12 PM, kenji hara wrote:https://github.com/D-Programming-Language/dmd/pull/476 The pull request implementing that enhancement. Kenji HaraGreat! Thank you. I hope that is merged soon. What do you think about emptyarray_t?
Oct 27 2011
Am 27.10.2011 18:14, schrieb Timon Gehr:On 10/27/2011 02:12 PM, kenji hara wrote:Sounds good to me. -- Kind Regards Benjamin Thauthttps://github.com/D-Programming-Language/dmd/pull/476 The pull request implementing that enhancement. Kenji HaraGreat! Thank you. I hope that is merged soon. What do you think about emptyarray_t?
Oct 27 2011