<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 02/12/2012 09:56 PM, Mike Wey wrote:
<blockquote cite="mid:4F382769.5000400@mikewey.eu" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 02/12/2012 09:08 PM, Walter Bright wrote:
<blockquote cite="mid:4F381C2F.4010806@digitalmars.com"
type="cite"><br>
It's a Base, not an Object. It can be converted to an Object. </blockquote>
<br>
Doesn't that break Polymorphism?<br>
<br>
You should be able to use Base as if it is an Object without a
cast. <span class="Apple-style-span" style="color: rgb(0, 0, 0);
font-family: sans-serif; font-size: 13px; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing:
normal; line-height: 19px; orphans: 2; text-indent: 0px;
text-transform: none; white-space: normal; widows: 2;
word-spacing: 0px; background-color: rgb(255, 255, 255);"> </span>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<br>
<span class="Apple-style-span" style="color: rgb(0, 0, 0);
font-family: sans-serif; font-size: 13px; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing:
normal; line-height: 19px; orphans: 2; text-align: -webkit-auto;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
background-color: rgb(255, 255, 255); "></span> <br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dmd-beta mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
<br>
According to the documentation a == b is rewritten to
.object.opEquals(a, b); if a and b are both objects.<br>
And while .object.opEquals(new Base(), new Base()); compiles without
an error, and gives the expected result at runtime. using == is an
compiletime error when a opCast is supplied without adding one for
Object.<br>
<br>
Base being derived from Object there would be no need for a cast
when you want to use it as an Object.<br>
<br>
Adding an opCast overload for Object solves the compiletime error
but, the added opCast doesn't do anything:<br>
<br>
Base opCast(T)()<br>
if ( is(T == Object) )<br>
{<br>
return this;<br>
}<br>
<br>
Yes i used Base as the return type, that works because base is
derived from Object.<br>
<br>
Is the behavior of the beta really correct?<br>
</body>
</html>