<div class="gmail_quote">On Thu, Dec 30, 2010 at 12:18 PM, spir <span dir="ltr"><<a href="mailto:denis.spir@gmail.com">denis.spir@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Thu, 30 Dec 2010 08:15:51 -0500<br>
<div class="im">bearophile <<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>> wrote:<br>
<br>
</div><div><div></div><div class="h5">> > But some language types (or machine types) can have very diverse _human_ semantics, and thus be used for various purposes which should, but cannot, be considered different:<br>

><br>
> You may wrap your data in a struct.<br>
<br>
</div></div>Yes, thank you for this hint. A kind of proxy struct? It can indeed be used everywhere performance is not critical. But a side issue is that it requires the 'alias this' hack, I guess, or forwarding every operation to the actual, but wrapped, element. What do you think<br>

<div><div></div><div class="h5"><br>
Denis<br>
-- -- -- -- -- -- --<br>
vit esse estrany ☣<br>
<br>
<a href="http://spir.wikidot.com" target="_blank">spir.wikidot.com</a><br>
<br>
</div></div></blockquote></div><br>Why is performance harmed by the use of a struct? Wouldn't it be zero-overhead like C++'s std::auto_ptr?<div><br><div>Also, the alias this and the forward might be a real good solution. And a mixin like Luger's might be jackpot, really. I just dislike the use in:</div>
</div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; color: rgb(80, 0, 80); ">func2(Position(1)); // implicit conversion to int with alias this</span></div>
</div></blockquote><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br>
</span></font></div>I guess that can be actually a bug, not a feature :) Maybe one day the function signature changes slightly and the problem is further disguised because "you're obviously passing the right Position here"... when it's actually an "int count" thing. The "alias this" thing is a good shorthand when assigning, though:</span></font><div>
<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">int a = pos; // implicit conversion from Position to int instead of</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">int b = pos.base;</span></font></div></blockquote><div><div><div><br>-- <br>Atenciosamente / Sincerely,<br>
Guilherme ("n2liquid") Vieira<br>
</div></div></div></div>