borrowed pointers vs ref

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon May 12 14:15:38 PDT 2014


On Mon, 12 May 2014 16:36:12 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> 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.

Hm... the one piece that I think would be damaging is to not be able to  
take an address of the 'this' reference. It's probably OK to just use  
pointers and static functions in some cases, but member functions do not  
have that luxury. In other words, operators.

Big example would be a doubly linked list used with ~=.

-Steve


More information about the Digitalmars-d mailing list