digitalmars.D.learn - How do I call super or object.opAssign for classes?
- Andrej Mitrovic (18/18) Jul 23 2011 class Foo
- Steven Schveighoffer (4/22) Jul 25 2011 That's a bug, please file.
- Andrej Mitrovic (2/27) Jul 25 2011
- =?ISO-8859-1?Q?Diego_Canuh=E9?= (10/10) Jul 26 2011 Hi,
-
Steven Schveighoffer
(15/26)
Jul 26 2011
On Tue, 26 Jul 2011 07:54:54 -0400, Diego Canuh=C3=A9
class Foo { void opAssign(int bar) { } } void main() { auto foo = new Foo; foo = null; } test.d(17): Error: function test.Foo.opAssign (int bar) is not callable using argument types (void*) test.d(17): Error: cannot implicitly convert expression (null) of type void* to int I just wanted to implement one opAssign method for assigning a specific type, but now I've ran into the issue that assigning class objects to null doesn't work anymore.. :/
Jul 23 2011
On Sat, 23 Jul 2011 12:23:07 -0400, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:class Foo { void opAssign(int bar) { } } void main() { auto foo = new Foo; foo = null; } test.d(17): Error: function test.Foo.opAssign (int bar) is not callable using argument types (void*) test.d(17): Error: cannot implicitly convert expression (null) of type void* to int I just wanted to implement one opAssign method for assigning a specific type, but now I've ran into the issue that assigning class objects to null doesn't work anymore.. :/That's a bug, please file. -Steve
Jul 25 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6378 On 7/25/11, Steven Schveighoffer <schveiguy yahoo.com> wrote:On Sat, 23 Jul 2011 12:23:07 -0400, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:class Foo { void opAssign(int bar) { } } void main() { auto foo = new Foo; foo = null; } test.d(17): Error: function test.Foo.opAssign (int bar) is not callable using argument types (void*) test.d(17): Error: cannot implicitly convert expression (null) of type void* to int I just wanted to implement one opAssign method for assigning a specific type, but now I've ran into the issue that assigning class objects to null doesn't work anymore.. :/That's a bug, please file. -Steve
Jul 25 2011
Hi, isn't that the way it's supposed to work? I mean void show(int a) { writeln(a); } void main() { show(null); } won't compile either. Shouldn't bar be some kind of pointer? btw, today I read "opAssign can no longer be overloaded for class objects" here: http://www.d-programming-language.org/features2.html is that no longer valid?
Jul 26 2011
On Tue, 26 Jul 2011 07:54:54 -0400, Diego Canuh=C3=A9 <canuhedc gmail.co= m> = wrote:Hi, isn't that the way it's supposed to work? I mean void show(int a) { writeln(a); } void main() { show(null); } won't compile either. Shouldn't bar be some kind of pointer?null should be considered as the type of the class, not void *. You = should not be able to override the behavior of opAssign as it pertains t= o = assigning to a class instance. In other words, you should *never* be ab= le = to override x =3D null where x is a class instance.btw, today I read "opAssign can no longer be overloaded for class =objects" here: http://www.d-programming-language.org/features2.html is that no longer valid?Here is the spec. I would not trust that features2, it's probably out o= f = date. http://www.d-programming-language.org/operatoroverloading.html#Assignmen= t -Steve
Jul 26 2011