pointers, functions, and uniform call syntax
Carl Sturtivant
sturtivant at gmail.com
Mon Sep 3 12:51:49 PDT 2012
Just to be pellucidly clear, the case you think likely has merit
is for an enhancement so that
S* p; //suitably initialized
can e.g. make the call
p.func(3);
of
void func(S s, int i) { ... }
or
void func(ref S s, int i) { ... }
right?
(Where it's important that the S parameter is first in the usual
way, and the overloading rules are suitably amended to give this
interpretation suitably low priority.)
Whereas you do not (correct me if I'm wrong) think that an
implicit conversion of S* to ref S (or S) on function call is a
good idea, e.g.
S* p; //suitably initialized
cannot e.g. make the call
func(p, 3);
of
void func(S ref s, int i) { ... }
or
void func(S s, int i) { ... }
So you've 'solved' one of the two calls that monarch_dodra
indicated concern about, but not the other, which you think
should require explicit indirection.
Assuming I've summarized the pragmatics of your post correctly
(apologies otherwise), what is the reason for the non-uniformity
here? As monarch_dodra points out, the dangers are the same in
both calls. So if D is OK with one, why not with the other, which
presents the possibility of nice syntactic simplification.
I guess this is tantamount to asking you why implicit conversion
of S* to ref S would be so bad in general if you'll effectively
permit that in certain cases (the call p.func(3) amounts to
exactly that).
It'd be nice to hear the D insider view on this.
Carl.
More information about the Digitalmars-d
mailing list