equivariant functions

Bill Baxter wbaxter at gmail.com
Tue Oct 14 19:36:41 PDT 2008


On Wed, Oct 15, 2008 at 11:20 AM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Bill Baxter wrote:
>>
>> On Wed, Oct 15, 2008 at 11:02 AM, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>
>>> 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);
>
> If you'd ask for my opinion, I'd say the show of inout stops here.
>
>>>> 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?
>
> Too many. I mean most all. Essentially you can only implement identity and
> min/max :o). Think of stripl when you need to return a slice of the incoming
> argument.

But stripl just needs constness propagation, right?  So it's handled
by Steve's inout proposal.  The return thing just handles propagation
of base type.  I assume he has some way to combine inout with return
when you want to manipulate both constness and base type.

Maybe I've missed something though...

--bb



More information about the Digitalmars-d mailing list