Re: In what situation can new Struct() return null?

2019-05-11 Thread faissaloo via Digitalmars-d-learn
On Friday, 10 May 2019 at 17:54:44 UTC, H. S. Teoh wrote: Perhaps try Dustmite on it? AFAIK, calling new on a struct should never return null. So there must be something else not quite right here. But without actual code it's anybody's guess as to what it might be. The last time I heard

Re: In what situation can new Struct() return null?

2019-05-10 Thread faissaloo via Digitalmars-d-learn
On Friday, 10 May 2019 at 12:19:29 UTC, Cym13 wrote: On Friday, 10 May 2019 at 10:11:51 UTC, faissaloo wrote: My program contains the following statement: auto newChildNode = new Node(); In debugging I have found that this pointer evaluates to null, what could cause this? I should have

In what situation can new Struct() return null?

2019-05-10 Thread faissaloo via Digitalmars-d-learn
My program contains the following statement: auto newChildNode = new Node(); In debugging I have found that this pointer evaluates to null, what could cause this? I should have plenty of memory, my only other idea is some sort of heap corruption.

Re: alias this and struct allocation

2019-05-06 Thread faissaloo via Digitalmars-d-learn
On Monday, 6 May 2019 at 15:17:37 UTC, aliak wrote: Do you have an example of a referenced object turning to null? We may be able to spot something Unfortunately I haven't managed to produce an example any smaller than my entire codebase

alias this and struct allocation

2019-05-06 Thread faissaloo via Digitalmars-d-learn
I've been having some memory issues (referenced objects turning to nulls for no apparent reason) and I was wondering if I've misunderstood how allocation works when instantiating a struct that uses alias this: import std.stdio; struct Parent { int a;

Re: Mixin can't access library symbols?

2019-05-03 Thread faissaloo via Digitalmars-d-learn
On Friday, 3 May 2019 at 17:51:39 UTC, Adam D. Ruppe wrote: On Friday, 3 May 2019 at 17:48:50 UTC, faissaloo wrote: How can I get a mixin to implicitly include the symbols from its surrounding context? Is this possible? What's your big picture goal? Do you have sample code you have tried so

Mixin can't access library symbols?

2019-05-03 Thread faissaloo via Digitalmars-d-learn
How can I get a mixin to implicitly include the symbols from its surrounding context? Is this possible?

getOverloads trait doesn't work on functions

2019-04-13 Thread faissaloo via Digitalmars-d-learn
I'm trying to use: ``` __traits(getOverloads, fn) ``` But I get the error expected 2 arguments for getOverloads but had 1 Is there an alternative I can use?

Re: Does new X() return a pointer or not?

2019-04-06 Thread faissaloo via Digitalmars-d-learn
Thanks alot everyone for your replies, this makes sense now.

Does new X() return a pointer or not?

2019-04-06 Thread faissaloo via Digitalmars-d-learn
I have the following function static Component* constructComponent(int value) { return (new ComponentChild(value)); } ComponentChild is a derived class of Component. However, I get told that ComponentChild cannot be converted to Component*. I'm confused here,

Modulo that 'wraps' the number?

2019-01-20 Thread faissaloo via Digitalmars-d-learn
In Python -1%3 == 2 however in D -1%3 == -1 Is there a standard library function or something that gives me the Python version of modulo?

Re: Am I misusing with?

2019-01-19 Thread faissaloo via Digitalmars-d-learn
On Saturday, 19 January 2019 at 20:07:34 UTC, Rubn wrote: On Saturday, 19 January 2019 at 17:49:31 UTC, faissaloo wrote: [...] If you look at the implementation, "lines" is a struct. https://github.com/dlang/phobos/blob/v2.084.0/std/stdio.d#L4330 [...] Ah that makes some sense, thanks for

Am I misusing with?

2019-01-19 Thread faissaloo via Digitalmars-d-learn
This seems to work fine file = File("test.txt", "r"); with (file) { scope(exit) close(); foreach (string line; file.lines()) { line_array ~= line; } } however: file = File("test.txt", "r"); with (file) { scope(exit) close();

Re: .dup vs operation on all elements

2018-12-03 Thread faissaloo via Digitalmars-d-learn
On Monday, 3 December 2018 at 20:37:22 UTC, Jonathan M Davis wrote: On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: Are there any differences between these 2 methods of copying elements? double[] array = [ 1, 20, 2, 30, 7, 11 ]; // Non dup double[6]