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

Elronnd elronnd at elronnd.net
Wed Oct 20 22:50:14 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.

FWIW the 'non-nullable & explicitly nullable pointers' proposal 
resolves this.  Because the point of such pointers is that they 
always point at exactly one object (or at nothing), there is no 
point in indexing or adding anything to them etc., so such 
overloaded operators can be forwarded.  (As x.y -> (*x).y, so 
x.opUnary!"++" -> (*x).upUnary!"++".)

However I just realised unary * can be overloaded.  Obviously *x 
should be a dereference.  But as that is a fairly fringe use case 
(and the point of the exercise was to ignore compatibility 
anyway), I think it can be safely steamrolled.

More information about the Digitalmars-d mailing list