<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 31 March 2014 18:16, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 3/31/2014 12:51 AM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Now it's deceptive that it's a pointer, and the pointer semantics are not<br>
suppressed. It might be surprising to find that a type that doesn't look like a<br>
pointer behaves like a pointer.<br>
You lose access to the operators, indexing/slicing etc, etc.<br>
I don't see how this is a reasonable comparison to 'class' as a reference type<br>
by definition.<br>
</blockquote>
<br></div>
Of course it's reasonable - not many classes overload operators.<br></blockquote><div><br></div><div>Is there a way to disable indexed dereferencing? Slicing?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


The point is, there are numerous solutions available, you aren't stuck with one solution for every problem.<br></blockquote><div><br></div><div>I just wouldn't go so far as to call these alternatives 'solution's. A pointer is a pointer.</div>
<div>Calling it a reference type is a stretch. While it can be indexed, sliced, and operators don't work, I don't think this is a compelling solution in very many contexts, and certainly not a general solution.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And, you can use 'alias this' as Adam showed to create a type with fully customized behavior - you don't have to change the language to prove your ideas.<br>
</blockquote></div><br></div><div class="gmail_extra">I haven't made any suggestion to change the language, I just said that adam's idea (well, not necessarily his idea, it seems to be an established pattern) is a rather elaborate hack; in many cases the boilerplate exceeds the volume of the useful code. The whole pointer-to-Impl + getter property + alias this + etc pattern is quite a lot of boilerplate.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">It's a really common pattern, it's obviously very useful, but it's surprising to me that people think that it's like, 'cool'.</div>
<div class="gmail_extra">I get why it's done, and it's cool that D can do this (I use it a lot in my code), but I don't feel it's particularly elegant.</div></div>