On 31 March 2014 17:28, Walter Bright <[email protected]> wrote:
> On 3/30/2014 8:32 PM, Adam D. Ruppe wrote: > >> On Monday, 31 March 2014 at 03:25:11 UTC, Manu wrote: >> >>> I also feel quite dirty using pointers in D where there is a dedicated >>> reference type available. I don't want * and & to appear everywhere in >>> my D code. >>> >> >> structs can pretty easily be reference types too: >> > > Or just: > > alias S* C; > > Voila! Use C as the type instead of S*. The reason this works out so well > in D is because C.member works (no need to use -> ) > Now it's deceptive that it's a pointer, and the pointer semantics are not suppressed. It might be surprising to find that a type that doesn't look like a pointer behaves like a pointer. You lose access to the operators, indexing/slicing etc, etc. I don't see how this is a reasonable comparison to 'class' as a reference type by definition.
