DIP60: @nogc attribute

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 19 06:40:26 PDT 2014


On Saturday, 19 April 2014 at 10:07:46 UTC, Jacob Carlborg wrote:
> On 2014-04-18 18:17, Brad Anderson wrote:
>
>> Problems like how toUpperInPlace would still allocate (with
>> gusto) could much more easily be recognized and fixed with 
>> @nogc available.
>
> toUpperInPlace should be removed.

Nonsense. It still works 99% of the time (I think only a subset 
of 100 letters in all of Unicode are affect, and even then, 
another 100 of them *shrink* on toUpper). It is really useful. It 
avoids *needles* allocations. Removing it would be more harmful 
than useful.

I'm pretty confident that most of the time it is used, people 
don't care *that* much that *absolutely* no allocation takes 
place. They just don't want to be wasteful.

> It cannot work reliable in place.

Rename "toUpperMaybeInPlace".

Then, for those that absolutely *can't* allocate provide a better 
interface. For example:
`void toUpper(S, O)(S s, ref O o);`

Burden on the caller to make it "inplace" from that (or to 
allocate accordingly when inplace is not possible).


More information about the Digitalmars-d mailing list