Re: How to get nogc to work with manual memory allocation

2014-09-05 Thread via Digitalmars-d-learn
On Friday, 5 September 2014 at 06:43:56 UTC, monarch_dodra wrote: On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote: On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc funct

Re: How to get nogc to work with manual memory allocation

2014-09-04 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote: On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call non-@nogc fu

Re: How to get nogc to work with manual memory allocation

2014-09-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 04/09/14 22:30, Kagamin wrote: emplace calls constructor, and constructor can't be realistically required to be nogc. It depends on the constructor. Similar for destroy. But if the constructor is @nogc or if there's a default constructor. -- /Jacob Carlborg

Re: How to get nogc to work with manual memory allocation

2014-09-04 Thread Kiith-Sa via Digitalmars-d-learn
On Sunday, 24 August 2014 at 08:03:11 UTC, Bienlein wrote: Hello, I was having a look at the new nogc annotation and therefore wrote some code that creates an instance on the heap bypassing the GC (code adapted from http://dpaste.dzfl.pl/2377217c7870). Problem is that calls to call the class'

Re: How to get nogc to work with manual memory allocation

2014-09-04 Thread Kagamin via Digitalmars-d-learn
On Sunday, 24 August 2014 at 13:27:01 UTC, Jacob Carlborg wrote: On 2014-08-24 14:18, Kagamin wrote: Shouldn't emplace and destroy infer their attributes instead of strictly annotating them as nogc. If they are templates, I guess they should. I don't know how good the compiler is at inferri

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-08-24 14:18, Kagamin wrote: Shouldn't emplace and destroy infer their attributes instead of strictly annotating them as nogc. If they are templates, I guess they should. I don't know how good the compiler is at inferring attributes. I also haven't looked at the source code for these

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread Kagamin via Digitalmars-d-learn
On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote: On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call non-@nogc fu

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread bearophile via Digitalmars-d-learn
Bienlein: @nogc is meant mostly for stack-allocation. Ah, I missed that. Thanks for telling me. @nogc is also for allocation from the C heap, despite this is less common :-) Bye, bearophile

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread eles via Digitalmars-d-learn
On Sunday, 24 August 2014 at 08:48:03 UTC, bearophile wrote: Bienlein: things in such Limbo for several years). decades

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2014-08-24 10:03, Bienlein wrote: I have omitted the code for the TestClass class to save space. Problem is that the compiler outputs this: Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call non-@nogc function 'core.exception.onOutOfMemoryError' Error: @nogc function 'mai

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread Bienlein via Digitalmars-d-learn
On Sunday, 24 August 2014 at 08:48:03 UTC, bearophile wrote: Perhaps there are ways, but note that @nogc is meant mostly for stack-allocation. Ah, I missed that. Thanks for telling me. I changed nogcDel now to null out the deallocated object: void nogcDel(T)(ref T obj) { import core.std

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread bearophile via Digitalmars-d-learn
Bienlein: Is there a way to get around this? Perhaps there are ways, but note that @nogc is meant mostly for stack-allocation. In general when in D you have to write lot of hairy code to do something, it means that in most cases you shouldn't do that something. When calling delete t the

How to get nogc to work with manual memory allocation

2014-08-24 Thread Bienlein via Digitalmars-d-learn
Hello, I was having a look at the new nogc annotation and therefore wrote some code that creates an instance on the heap bypassing the GC (code adapted from http://dpaste.dzfl.pl/2377217c7870). Problem is that calls to call the class' constructor, destructor and others can't be called anymore