DIP69 - Implement scope for escape proof references

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 7 13:29:51 PST 2014


On 12/7/2014 6:12 AM, Dicebot wrote:
> But from existing cases it doesn't seem working good enough. For example, not
> being able to represent idiom of `scope ref int foo(scope ref int x) { return x;
> }` seems very limiting.

   scope ref int foo(ref int x);

will do it.


> I also don't consider `ref` design as a storage class any kind of success at all
> and generally agree with Manu on this topic. At the same time alternative
> proposals that make it a qualifier (like Marc did) do impact existing language
> much more and this no small concern.

My experience with C++ ref as type qualifier is very, very bad. It's a special 
case EVERYWHERE. Doing type deduction with it is an exercise in a completely 
baffling set of rules and a different rule for every occasion - Scott Meyers has 
a great piece on this.

There are probably only a handful of people on the planet who actually 
understand C++ ref. I wished very hard to avoid that with D ref.



More information about the Digitalmars-d mailing list