Re: std.container.array.Array is not @nogc?

2017-01-15 Thread Jack Stouffer via Digitalmars-d-learn

On Sunday, 15 January 2017 at 13:08:52 UTC, drug007 wrote:

Thanks for answer. Looking forward for your PR.


https://github.com/dlang/phobos/pull/5036


Re: std.container.array.Array is not @nogc?

2017-01-15 Thread drug007 via Digitalmars-d-learn

On 15.01.2017 15:49, Jack Stouffer wrote:


No you're not.

Array was designed before the @nogc attribute was created, so it wasn't
coded with it's requirements in mind. Looking at the code, Array
allocates GC memory for exception throwing in some cases. These can and
should be changed to asserts.

I am writing a PR now to fix this. There doesn't seem to be too many
cases to fix.

Thanks for answer. Looking forward for your PR.


Re: std.container.array.Array is not @nogc?

2017-01-15 Thread Jack Stouffer via Digitalmars-d-learn

On Sunday, 15 January 2017 at 11:47:06 UTC, drug007 wrote:

Is there a way to use Array in @nogc code:
```
import std.container.array : Array;

@nogc:
void main(string[ ] args)
{
   Array!int ai;
   ai ~= 1;
   assert(ai[0] == 1);
}
```
fails:
```
main.d(8): Error: @nogc function 'D main' cannot call non-@nogc 
function 'std.container.array.Array!int.Array.opOpAssign!("~", 
int).opOpAssign'



main.d(9): Error: @nogc function 'D main' cannot call non-@nogc 
function 'std.container.array.Array!int.Array.opIndex'

```
am I doing something wrong?


No you're not.

Array was designed before the @nogc attribute was created, so it 
wasn't coded with it's requirements in mind. Looking at the code, 
Array allocates GC memory for exception throwing in some cases. 
These can and should be changed to asserts.


I am writing a PR now to fix this. There doesn't seem to be too 
many cases to fix.


std.container.array.Array is not @nogc?

2017-01-15 Thread drug007 via Digitalmars-d-learn

Is there a way to use Array in @nogc code:
```
import std.container.array : Array;

@nogc:
void main(string[ ] args)
{
   Array!int ai;
   ai ~= 1;
   assert(ai[0] == 1);
}
```
fails:
```
main.d(8): Error: @nogc function 'D main' cannot call non-@nogc function 
'std.container.array.Array!int.Array.opOpAssign!("~", int).opOpAssign' 



main.d(9): Error: @nogc function 'D main' cannot call non-@nogc function 
'std.container.array.Array!int.Array.opIndex'

```
am I doing something wrong?