equivariant functions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Oct 14 19:02:23 PDT 2008


Steven Schveighoffer wrote:
> I'll reiterate my proposal:
> 
> inout(X) f(inout(Y) y, inout(Z) z)
> 
> where inout means 'the greatest common constancy of all variables that are 
> declared inout'.  Again, not in love with inout, but inout kind of reads 
> 'you get out what you put in', and it is a 'free' keyword.

Ugh. This doesn't quite work because it mimics the "true" solution (= 
bind an alias to the qualifier) by always calling that alias "inout" or 
whatever keyword name. This problem becomes apparent when you try to 
nest declarations:

inout(X) fun(inout(Y) function(inout(Z)) gun);

Now you tell me which inout goes where.

> and for 3:
> 
> X f(return X x);
> 
> where return means 'this function will return x'.  The return statements in 
> this function are all required to return the value of x.  (x cannot be 
> rebindable inside the function).

I think this is a bit too particular and too restrictive to be useful. 
Maybe we can all be happy with whatever solution we find for the general 
case. It's not that much to type afterall.


Andrei



More information about the Digitalmars-d mailing list