DIP69 - Implement scope for escape proof references

via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 6 05:41:00 PST 2014


On Saturday, 6 December 2014 at 09:51:15 UTC, Manu via 
Digitalmars-d wrote:
> I've been over it so many times.
> I'll start over if there is actually some possibility I can 
> convince
> you? Is there?
>
> I've lost faith that I am able to have any meaningful impact on 
> issues
> that matter to me, and I'm fairly sure at this point that my
> compounded resentment and frustration actually discredit my 
> cause, and
> certainly, my quality of debate.
> I'm passionate about these things, but I'm also extremely 
> frustrated.
> To date, whenever I have engaged in a topic that I *really* care
> about, it goes the other direction. To participate has proven 
> to be
> something of a (very time consuming) act of masochism.

That's very sad to hear. I think you have brought up some very 
important points, especially from a practical point of view.

>
>
> I __absolutely objected__ to 'auro ref' when it appeared. I 
> argued
> that it was a massive mistake, and since it's introduction and
> experience with it in the wild, I am more confident in that 
> conviction
> than ever.
>
> As a programmer, I expect control over whether code is a 
> template, or
> not. 'ref' doesn't have anything to do with templates. 
> Confusing these
> 2 concepts was such a big mistake.
> auto ref makes a template out of something that shouldn't be a
> template. It's a particularly crude hack to address a prior 
> mistake.
> ref should have been fixed at that time, not compounded with 
> layers of
> even more weird and special-case/non-uniform behaviours above 
> it.
>
>
> There has been a couple of instances where the situation has 
> been
> appropriate that I've tried to make use of auto ref, but in 
> each case,
> the semantics have never been what I want.
> auto ref presumes to decide for you when something should be a 
> ref or
> not. It prescribes a bunch of rules on how that decision is 
> made, but
> it doesn't know what I'm doing, and it gets it wrong.
> In my experience, auto ref has proven to be, at best, completely
> useless. But in some cases I've found where I bump into it in 
> 3rd
> party code, it's been a nuisance, requiring me to wrap it away.

I tend to agree with this. Here's an example of the dangers:

https://github.com/deadalnix/libd/pull/7

In this case, `auto ref` accepted a class by reference, because 
it chooses ref-ness based on whether you pass an lvalue or an 
rvalue. This is not very helpful. I agree that `ref` isn't 
something that should ever be inferred, because it affects the 
semantics of the function. Either the function requires `ref` 
semantics, or not. It doesn't depend on how it is called.


More information about the Digitalmars-d mailing list