<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1404.34">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 12.0px; font: 12.0px Helvetica; color: #011892}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica}
p.p6 {margin: 0.0px 0.0px 0.0px 12.0px; font: 12.0px Helvetica; color: #011892; min-height: 14.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica; color: #011892; min-height: 14.0px}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica; color: #008e00; min-height: 14.0px}
p.p9 {margin: 0.0px 0.0px 0.0px 24.0px; font: 12.0px Helvetica; color: #008e00}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #929292}
</style>
</head>
<body>
<p class="p1">On 2016-02-06 14:33:57 +0000, Marc Schütz said:</p>
<p class="p2"><br></p>
<p class="p3">I don't see why this wouldn't work, if you've in fact covered all combinations.</p>
<p class="p4"><br></p>
<p class="p5">It works, the problem was that castSwitch returns something and I didn't "catch" it.</p>
<p class="p4"><br></p>
<p class="p3">It's similar to how castSwitch is implemented, though the double casts are inefficient. You could use:</p>
<p class="p6"><br></p>
<p class="p3">if(auto inta = cast(IntV) a) {</p>
<p class="p3"><span class="Apple-converted-space"> </span>if(auto intb = cast(IntV) b) {</p>
<p class="p3"><span class="Apple-converted-space"> </span>return new IntV(inta.num + intb.num);</p>
<p class="p3"><span class="Apple-converted-space"> </span>}</p>
<p class="p3">}</p>
<p class="p4"><br></p>
<p class="p5">Yes, thanks. Was on my list.</p>
<p class="p7"><br></p>
<p class="p3">(Again, this can be automated.)</p>
<p class="p4"><br></p>
<p class="p5">How? Do you mean by castSwitch?</p>
<p class="p4"><br></p>
<p class="p8"><br></p>
<p class="p9">I read this here: https://github.com/D-Programming-Language/phobos/pull/1266#issuecomment-53507509 (functional pattern matching) but it seems it won't be implemented... at the end of the day what I simulate are poor-mans-multimethods</p>
<p class="p6"><br></p>
<p class="p3">As I read the discussion, it was just decided to defer the more complex version of castSwitch for later, but it wasn't rejected.</p>
<p class="p4"><br></p>
<p class="p5">Well... yes, "won't be implemented in the near future" Anyway, it's not available at the moment, so looking at other ways.</p>
<p class="p10"><br></p>
<p class="p11">--<span class="Apple-converted-space"> </span></p>
<p class="p11">Robert M. Münch</p>
<p class="p11">http://www.saphirion.com</p>
<p class="p11">smarter | better | faster</p>
</body>
</html>