If you could make any changes to D, what would they look like?

Tejas notrealemail at gmail.com
Thu Oct 21 04:58:31 UTC 2021


On Wednesday, 20 October 2021 at 15:58:49 UTC, Adam D Ruppe wrote:
> On Wednesday, 20 October 2021 at 15:53:53 UTC, H. S. Teoh wrote:
>> Object* *is* the pointer.  There's nothing going on behind the 
>> scenes.
>
> well tho does obj++; move the pointer or call the operator on 
> the class?
>
> I don't think this syntax is ideal (I kinda prefer the old 
> `Object ref` proposal), but just it is something interesting to 
> think about.

Umm, do we have to do anything in this case?

It'll be the same as for structs:
```d
import std;

struct S{
     void opUnary(string s : "++")(){
     	writeln(`called opUnary!("++")()`);
     }
     int a;
}

void func(S* param){
     writeln((*param).a);
     (*param)++;
}
void main()
{
  	S s;
     func(&s);
}
```

You use `ref`, you can't do pointer arithmetic anymore.



More information about the Digitalmars-d mailing list