On Tuesday, 26 July 2016 at 01:07:27 UTC, Chris Wright wrote:
On Mon, 25 Jul 2016 15:46:54 +0000, bitwise wrote:

On Monday, 25 July 2016 at 07:43:34 UTC, rikki cattermole wrote:
I've been saying for a very long time we need @assumenogc attribute like we have @trusted for @safe.

So I'm not crazy then ;)

I'm wondering if Andrei and Walter consider @trusted a win though. They seem to have such firm stances on certain issues that it makes me wonder if they consider things like @trusted a liability.

Personally, I lean way to the side of flexibility, and believe a good language shouldn't force you to code a certain way(within reason). I feel like this type of feature is very reasonable.

     Bit

@nogc conflates "doesn't allocate memory from the GC heap because I don't want my application to use the GC at all" with "doesn't cause GC collection pauses".

The latter can have a @assumenogc annotation that works -- you call GC.disable and GC.enable as appropriate. The former can't.

Fair point.

You got me thinking though. For my intended usage, I don't actually need errors for GC allocation, and that may actually be inappropriate. I just need to make a best effort to avoid allocations.

Something like @warngc could work nicely. It could function exactly as @nogc with the exception that it issued warnings instead of errors.

I feel like some people reading this would be very quick to scold me for "premature optimization", and recommend a profiler, but in the case of 30-60 fps games, it's practically guaranteed that you will eventually run into performance problems. Especially on mobile devices. So proactively writing good code can save you a lot of headache.

    Bit

Reply via email to