digitalmars.D.learn - How do I call super or object.opAssign for classes?
- Andrej Mitrovic <andrej.mitrovich gmail.com> Jul 23 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Jul 25 2011
- Andrej Mitrovic <andrej.mitrovich gmail.com> Jul 25 2011
- =?ISO-8859-1?Q?Diego_Canuh=E9?= <canuhedc gmail.com> Jul 26 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Jul 26 2011
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
--20cf307c9d9a9f648a04a8f79951
Content-Type: text/plain; charset=ISO-8859-1
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?
--20cf307c9d9a9f648a04a8f79951
Content-Type: text/html; charset=ISO-8859-1
Hi,<br>isn't that the way it's supposed to work? I mean<br><br>void
show(int a) { writeln(a); }<br><br>void main() { show(null); }<br><br>won't
compile either.<br>Shouldn't bar be some kind of pointer?<br><br>
btw, today I read "opAssign can no longer be overloaded for class
objects" here:<br><br><a
href="http://www.d-programming-language.org/features2.html">http://www.d-programming-language.org/features2.html</a><br>
<br>is that no longer valid?<br>
--20cf307c9d9a9f648a04a8f79951--
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









"Steven Schveighoffer" <schveiguy yahoo.com> 