Re: Printing an std.container.Array

2015-04-17 Thread Bayan Rafeh via Digitalmars-d-learn
On Thursday, 16 April 2015 at 20:08:30 UTC, H. S. Teoh wrote: On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn wrote: Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs

Printing an std.container.Array

2015-04-16 Thread Bayan Rafeh via Digitalmars-d-learn
Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs the following: Array!int(RefCounted!(Payload, cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) The strange thing is that this works fine:

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
but please, take my words with a grain of salt. i'm in no way a representative of D devs. that is how *i* understand invariants. it seems to be consistent with the cases where invariant works, This is the first serious project I do with D, so I'm kind of discovering the language as I write

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
Bug report at https://issues.dlang.org/show_bug.cgi?id=14051

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-26 Thread Bayan Rafeh via Digitalmars-d-learn
you are trying to use invariants for the things that invariants can't (and must not) check. invariants are meant for checking *internal* *object* *consistency*. NOT correctness. NOT applicability. ONLY consistency. object can be in "inapplicable" state, but still consistent. Then I must have

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Bayan Rafeh via Digitalmars-d-learn
the thing is that your invariant is not a correct invariant at all. invariants are meant to check *internal* object consistency, not external conditions. compiler is free to call invariant block at any time after object is properly initialised (i.e. after ctor is complete) and is not executin

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Bayan Rafeh via Digitalmars-d-learn
On Sunday, 25 January 2015 at 22:46:56 UTC, Ali Çehreli wrote: On 01/25/2015 02:06 PM, Bayan Rafeh wrote: is invariant() called during the destruction phase? Something is fishy. import std.stdio; void main(){ writeln("entered main"); auto a = new A(); writeln("leaving main"); }

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Bayan Rafeh via Digitalmars-d-learn
On Sunday, 25 January 2015 at 19:15:54 UTC, ketmar wrote: On Sun, 25 Jan 2015 08:41:24 +, Bayan Rafeh wrote: I tried what you said and I think I see the problem. I managed to create an example program that duplicates the problem: import std.stdio; class A { string path; this(st

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Bayan Rafeh via Digitalmars-d-learn
On Sunday, 25 January 2015 at 08:39:42 UTC, Bayan Rafeh wrote: On Sunday, 25 January 2015 at 00:43:43 UTC, Vladimir Panteleev wrote: On Saturday, 24 January 2015 at 12:16:38 UTC, Bayan Rafeh wrote: This problem is a tough one. I've been getting this error when I run my unittests, and apparently

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Bayan Rafeh via Digitalmars-d-learn
On Sunday, 25 January 2015 at 00:43:43 UTC, Vladimir Panteleev wrote: On Saturday, 24 January 2015 at 12:16:38 UTC, Bayan Rafeh wrote: This problem is a tough one. I've been getting this error when I run my unittests, and apparently it is caused by attempting an allocation in the destructor fro

core.exception.InvalidMemoryOperationError@(0)

2015-01-24 Thread Bayan Rafeh via Digitalmars-d-learn
This problem is a tough one. I've been getting this error when I run my unittests, and apparently it is caused by attempting an allocation in the destructor from what little I could find online about the subject. The error is triggered once all my tests are complete, so I'm assuming the garba

Re: byKeyValue does not exist for associative arrays

2015-01-24 Thread Bayan Rafeh via Digitalmars-d-learn
On Saturday, 24 January 2015 at 11:18:57 UTC, ketmar wrote: On Sat, 24 Jan 2015 11:17:03 +, Bayan Rafeh wrote: Apparently byKeyValue does not exist for associative arrays, should it? void main() { int[string] a; a.byKeyValue(); //Error: byKeyValue doesn't exist. } If it shouldn

byKeyValue does not exist for associative arrays

2015-01-24 Thread Bayan Rafeh via Digitalmars-d-learn
Apparently byKeyValue does not exist for associative arrays, should it? void main() { int[string] a; a.byKeyValue(); //Error: byKeyValue doesn't exist. } If it shouldn't could someone remove it from the documentation? http://dlang.org/hash-map.html

Large binary size using std.regex

2014-08-23 Thread Bayan Rafeh via Digitalmars-d-learn
Compiling a simple program using std.regex: import std.regex; import std.stdio; void main(string[] args) { auto re = regex(args[1], "g"); foreach(line; stdin.byLine) if(line.match(re)) writeln(line); } Renders a 1.6 megabyte binary. Is that normal?