this(this) must be cheap and O(1)

deadalnix deadalnix at gmail.com
Sun Sep 25 12:17:53 PDT 2011


Le 25/09/2011 21:02, Peter Alexander a écrit :
> On 25/09/11 7:37 PM, deadalnix wrote:
>> Le 25/09/2011 04:52, Andrei Alexandrescu a écrit :
>>> On 9/24/11 9:31 PM, Michel Fortin wrote:
>>>> Perhaps I am missing the point. What would be gained by forcing
>>>> this(this) to be nothrow?
>>>
>>> It further frees the standard library to cater for the throwing case.
>>>
>>> Andrei
>>
>> If I understand, what is explained in this thread is things that the
>> standard lib can assume concerning this(this) ?
>>
>> So, in the end, I'm not disallowed to have an expensive this(this), but
>> I should expect that the standard lib will not behave optimally in this
>> case ?
>>
>> Or are we talking about some modification/restriction in the language ?
>
> I believe it's just the library. There's no way the language could
> reasonably enforce it anyway.
>
> It probably just means Phobos will do more copies than C++ would for
> example.

The language could enforce that this(this) had to be nothrowor whatever. 
Or make it a warning (warning : this(this) should be a nothrow function).

For the complexity, it is hard to come up with something at the laguage 
level.


More information about the Digitalmars-d mailing list