borrowed pointers vs ref

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 12 13:36:12 PDT 2014


It's been brought up more than once that the 'scope' storage class is an 
unimplemented borrowed pointer. But thinking a bit more along those lines, 
actually 'ref' fills the role of a borrowed pointer.

One particularly apropos behavior is that struct member functions pass 'this' by 
ref, meaning that members can be called without the inc/dec millstone.

ref is still incomplete as far as this goes, but we can go the extra distance 
with it, and then it will be of great help in supporting any ref counting solution.

What it doesn't work very well with are class references. But Andrei suggested 
that we can focus the use of 'scope' to deal with that in an analogous way.

What do you think?

Anyone want to enumerate a list of the current deficiencies of 'ref' in regards 
to this, so we can think about solving it?


More information about the Digitalmars-d mailing list