Ideas from the Chapel language (swap)

Derek Parnell derek at psych.ward
Wed Oct 3 16:38:46 PDT 2007


On Wed, 03 Oct 2007 14:53:57 -0400, Bruce Adams wrote:

> bearophile Wrote:
> 
>> The Cray Inc is designing the Chapel Language:
>> http://chapel.cs.washington.edu/
>> The following notes are from the specification V. 0.750:
>> http://chapel.cs.washington.edu/spec-0.750.pdf
>> I think it's rather cute, it looks like a cross between C++, Fortress and Python. Here are few things I think can be interesting for D designers too:
>> 
>> - Chap. 11.5 page 65, swap operator (useful but probably not enough to justify a new operator)
> 
> swap is very useful especially in exception safe programming.
> I would like to see swap used as the default implementation of D's transfer constructor (and C++0x's forthcoming move constructor)

Isn't a simple template such this sufficient?

template swap(TYPE)
{
    void swap(ref TYPE a, ref TYPE b)
    {
        synchronized
        {
          TYPE temp = a;
          a = b;
          b = temp;
        }
    }

}


-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list