www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Deprecate static opCall for structs?

reply Bill Baxter <wbaxter gmail.com> writes:
We now have struct constructors that do basically the same thing as a
static opCall.
Non-static opCall should still be ok, for implementing functors, but I
think having static opCall is just too confusing given struct literals
/ struct constructors.

Right now
struct S;
S(1,2) ;
could be 1) a static opCall, 2) a constructor call  3) a struct literal

That seems too many things sharing the same syntax to me.

--bb
Nov 20 2009
parent reply grauzone <none example.net> writes:
Bill Baxter wrote:
 We now have struct constructors that do basically the same thing as a
 static opCall.
 Non-static opCall should still be ok, for implementing functors, but I
 think having static opCall is just too confusing given struct literals
 / struct constructors.
 
 Right now
 struct S;
 S(1,2) ;
 could be 1) a static opCall, 2) a constructor call  3) a struct literal
 
 That seems too many things sharing the same syntax to me.
I'd vote for removing struct constructors and static opcalls, and to fix the struct initializer syntax (so that it can produce struct literals).
 --bb
Nov 20 2009
parent BCS <none anon.com> writes:
Hello grauzone,

 Bill Baxter wrote:
 
 We now have struct constructors that do basically the same thing as a
 static opCall.
 Non-static opCall should still be ok, for implementing functors, but
 I
 think having static opCall is just too confusing given struct
 literals
 / struct constructors.
 Right now
 struct S;
 S(1,2) ;
 could be 1) a static opCall, 2) a constructor call  3) a struct
 literal
 That seems too many things sharing the same syntax to me.
 
I'd vote for removing struct constructors and static opcalls, and to fix the struct initializer syntax (so that it can produce struct literals).
 --bb
 
Not going to happen, at run time, struct constructors superset struct literals. It should be possible to make them do the same at compile time.
Nov 23 2009