equivariant functions

Bill Baxter wbaxter at gmail.com
Tue Oct 14 19:15:58 PDT 2008


On Wed, Oct 15, 2008 at 11:02 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> 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.

Ew.  Yeh, that is sticky.  This will not be that common though.  Maybe
you could allow arguments/indexes on the inout for those cases?

  inout[0](X) fun(inout[0](Y) function(inout[1](Z)) gun);


>
>> 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.

So what's the use case you have in mind that that doesn't satisfy?

--bb



More information about the Digitalmars-d mailing list