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

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Vladimir Panteleev via Digitalmars-d-learn
On Sunday, 25 January 2015 at 08:41:25 UTC, Bayan Rafeh wrote: The solution was just to remove the delete a from the destructor if someone comes across this later. Could someone tell me why though? The non-reentrant bit applies to all GC operations, really - not just allocations. Explicit

Re: crash on args.getopt

2015-01-25 Thread Tobias Pankrath via Digitalmars-d-learn
On Sunday, 25 January 2015 at 10:21:34 UTC, Suliman wrote: But is it good practice to fail with exception during passing unknown parameters? Maybe std.getopt.config.passThrough should be as default? I really can't remember Apps that crush if pass to in unknown parameters. Almost all

Re: using the full range of ubyte with iota

2015-01-25 Thread bearophile via Digitalmars-d-learn
Vlad Levenfeld: What's this about !`[]` and std.range.uniform?? It's not in the documentation. It's an enhancement I have proposed. Bye, bearophile

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

Re: crash on args.getopt

2015-01-25 Thread Suliman via Digitalmars-d-learn
But is it good practice to fail with exception during passing unknown parameters? Maybe std.getopt.config.passThrough should be as default? I really can't remember Apps that crush if pass to in unknown parameters.

Re: What to do with InvalidMemoryOperationError

2015-01-25 Thread Nordlöw
On Sunday, 25 January 2015 at 00:44:07 UTC, Vladimir Panteleev wrote: I created a wiki page which I hope will help you solve this problem: http://wiki.dlang.org/InvalidMemoryOperationError Hope this helps. Great! Thanks!

Re: crash on args.getopt

2015-01-25 Thread FG via Digitalmars-d-learn
On 2015-01-25 at 11:42, Tobias Pankrath wrote: On Sunday, 25 January 2015 at 10:21:34 UTC, Suliman wrote: But is it good practice to fail with exception during passing unknown parameters? Maybe std.getopt.config.passThrough should be as default? I really can't remember Apps that crush if pass

Re: using the full range of ubyte with iota

2015-01-25 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Sunday, 25 January 2015 at 10:42:51 UTC, bearophile wrote: Vlad Levenfeld: What's this about !`[]` and std.range.uniform?? It's not in the documentation. It's an enhancement I have proposed. Hm. I had more something in mind like paramCast - a kind of big scissors that cut everything a

Re: using the full range of ubyte with iota

2015-01-25 Thread Tobias Pankrath via Digitalmars-d-learn
On Sunday, 25 January 2015 at 12:25:35 UTC, Dominikus Dittes Scherkl wrote: map!(x = fn(cast(ParameterTypeTuple!fn[0])x) but instead with map!(paramCast!fn) Because this is useful in more situations, e.g. in every place where you know the values would fit into the parameter (and for a

Re: using the full range of ubyte with iota

2015-01-25 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Sunday, 25 January 2015 at 13:03:16 UTC, bearophile wrote: Dominikus Dittes Scherkl: Because this is useful in more situations, Right, but it's still a cast. And in D you want to minimize the number of usages of casts. The proposed syntax iota![] is cast-safe. I don't case too much,

Re: Link errors with curl, libevent, OpenSSL

2015-01-25 Thread AndyC via Digitalmars-d-learn
On Sunday, 25 January 2015 at 15:11:33 UTC, AndyC wrote: On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote: On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: // import std.net.curl; import

Re: Conflicts with Import error - New to D, trying to build a new project

2015-01-25 Thread Gan via Digitalmars-d-learn
Thanks. I didn't realize that could conflict. On Sunday, 25 January 2015 at 21:22:50 UTC, Ali Çehreli wrote: On 01/25/2015 11:30 AM, Gan wrote: Here's a screenshot: http://cl.ly/image/2n282v0B1X2M The error is: /Users/Matt/Projects/spacecraft/source/Game/Game.d(0,0): Error: class

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread Ali Çehreli via Digitalmars-d-learn
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); } class A { File file; this() { writeln(this);

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: Turning Executable into Application?

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 03:36:32 UTC, Gan wrote: With Xamarin Studio I create a D project and run it. It runs an Executable Unix file through the terminal. How can I turn that into an Application that doesn't open the Terminal? Thanks. Have you tried running your executable from the

Question about Allocating

2015-01-25 Thread Gan via Digitalmars-d-learn
I've been working on my game and am getting some pretty gnarly memory problems. I think it's how I'm allocating. Sometimes when I use variables I can do Color(255, 255, 255). But why is that different than new Color(255, 255, 255)? Same when I'm making arrays. new int[](0) vs []. What's the

vibe.d error

2015-01-25 Thread Phil via Digitalmars-d-learn
dub init name vibe.d cd name dub Results in Fetching libevent 2.0.1+2.0.16... Error executing command upgrade: Failed to download http://code.dlang.org/packages/libevent/2.0.1%252B2.0.16.zip: 404 Not Found I'm not sure if the error is the file not being there or dub looking there. Is there

Re: using the full range of ubyte with iota

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 14:11:09 +, Dominikus Dittes Scherkl wrote: On Sunday, 25 January 2015 at 13:03:16 UTC, bearophile wrote: Dominikus Dittes Scherkl: Because this is useful in more situations, Right, but it's still a cast. And in D you want to minimize the number of usages of casts.

Re: Sqlite

2015-01-25 Thread Paul via Digitalmars-d-learn
I'd like to vary the query based on input but if I try to move the string out of the sqlite3_exec call like this: string sqlStatement = CREATE TABLE people(id INT PRIMARY KEY NOT NULL, surname TEXT NOT NULL);; result = sqlite3_exec(db, sqlStatement, aCallback, null, msg); ...it won't

Re: Sqlite

2015-01-25 Thread Tobias Pankrath via Digitalmars-d-learn
On Sunday, 25 January 2015 at 18:15:21 UTC, Paul wrote: I'd like to vary the query based on input but if I try to move the string out of the sqlite3_exec call like this: string sqlStatement = CREATE TABLE people(id INT PRIMARY KEY NOT NULL, surname TEXT NOT NULL);; result = sqlite3_exec(db,

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
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(string p) { path = p; } ~this() {

Re: Sqlite

2015-01-25 Thread Paul via Digitalmars-d-learn
On Sunday, 25 January 2015 at 18:19:47 UTC, Tobias Pankrath wrote: Only string literals convert to const(char)*, because only for them it is guaranteed that they are null terminated. For everything else use toStringz. So, as a trivial example, is this how it's done?: string semiC = ;; const

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Mon, 26 Jan 2015 05:25:48 +, Bayan Rafeh wrote: There are 2 problems here: 1. By definition, after the destructor is called the object state is destroyed. It makes no sense to check the invariant after the destructor is called because there is no state for us to check. i agree that

Re: Turning Executable into Application?

2015-01-25 Thread Gan via Digitalmars-d-learn
On Monday, 26 January 2015 at 06:37:34 UTC, tcak wrote: On Monday, 26 January 2015 at 03:36:32 UTC, Gan wrote: With Xamarin Studio I create a D project and run it. It runs an Executable Unix file through the terminal. How can I turn that into an Application that doesn't open the Terminal?

Turning Executable into Application?

2015-01-25 Thread Gan via Digitalmars-d-learn
With Xamarin Studio I create a D project and run it. It runs an Executable Unix file through the terminal. How can I turn that into an Application that doesn't open the Terminal? Thanks.

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

Re: Difference between concatenation and appendation

2015-01-25 Thread WhatMeWorry via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:57:04 UTC, bearophile wrote: Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile Perfect! Thank

Re: Difference between concatenation and appendation

2015-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 26, 2015 01:17:15 WhatMeWorry via Digitalmars-d-learn wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about

Re: Turning Executable into Application?

2015-01-25 Thread tcak via Digitalmars-d-learn
On Monday, 26 January 2015 at 03:36:32 UTC, Gan wrote: With Xamarin Studio I create a D project and run it. It runs an Executable Unix file through the terminal. How can I turn that into an Application that doesn't open the Terminal? Thanks. I use MonoDevelop. I haven't tried that but in

Re: Link errors with curl, libevent, OpenSSL

2015-01-25 Thread AndyC via Digitalmars-d-learn
On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote: On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: // import std.net.curl; import std.stdio; void main() { writeln(get(dlang.org)); }

Re: using the full range of ubyte with iota

2015-01-25 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Sunday, 25 January 2015 at 12:56:14 UTC, Tobias Pankrath wrote: On Sunday, 25 January 2015 at 12:25:35 UTC, Dominikus Dittes Scherkl wrote: map!(x = fn(cast(ParameterTypeTuple!fn[0])x) but instead with map!(paramCast!fn) Because this is useful in more situations, e.g. in every place

unittest with Visual D

2015-01-25 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
I finaly got managed to install Visual D on my Windows PC (thanks to the new community version of Visual Studio), but the cool point Compile and Run seems to have a problem with some of my unittests: I get the error template instance xy is not defined if a specific instantiation is not used

Suggestions on what to use for testing?

2015-01-25 Thread Johannes Bornhold via Digitalmars-d-learn
Just doing my first moves around with D and I realize that I want to structure my tests. Wondering what you are using as a test runner / test framework on top of plain unittest support in D itself? So far I am ending up with adding comments into my code to structure things:

Re: using the full range of ubyte with iota

2015-01-25 Thread bearophile via Digitalmars-d-learn
Dominikus Dittes Scherkl: Because this is useful in more situations, Right, but it's still a cast. And in D you want to minimize the number of usages of casts. The proposed syntax iota![] is cast-safe. Bye, bearophile

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-25 Thread Suliman via Digitalmars-d-learn
Adam, I understood how to select URLs, but how extract values of attributes from such selection? a href=/ class=post-tag title=show questions tagged 'javascript' rel=somedata I need extract data inside rel (somedata)

Re: Conflicts with Import error - New to D, trying to build a new project

2015-01-25 Thread Ali Çehreli via Digitalmars-d-learn
On 01/25/2015 11:30 AM, Gan wrote: Here's a screenshot: http://cl.ly/image/2n282v0B1X2M The error is: /Users/Matt/Projects/spacecraft/source/Game/Game.d(0,0): Error: class Game.Game.Game conflicts with import Game.Game.Game at source/Game/Game.d(2) (spacecraft) I figure it's because I did

Re: using the full range of ubyte with iota

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 20:42:47 +, Dominikus Dittes Scherkl wrote: But in a function you need the cast anyway: ubyte swapNibbles(ubyte x) { return (x4) | (x4); } // compiler not happy sure, it can't be happy, as `x` is promoted to int in the expression, so the expression result is `int`.

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;

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 25 January 2015 at 21:24:06 UTC, Suliman wrote: I need extract data inside rel (somedata) string s = element.rel;

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 22:06:26 +, Bayan Rafeh wrote: This is another problematic example program: import std.stdio; void main(){ auto a = new A(/tmp/invalid); } class A { File f; string path; this(string path) { this.path = path; //f =

Re: Difference between concatenation and appendation

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:17:17 UTC, WhatMeWorry wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing

Re: Difference between concatenation and appendation

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:57:04 UTC, bearophile wrote: Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile Thanks. That

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 22:06:26 +, Bayan Rafeh wrote: p.s. yet creating new `File` in invariant is wrong nevertheless, as it changes the program state. invariant checks SHOULD NEVER CHANGE THE PROGRAM STATE. signature.asc Description: PGP signature

Difference between concatenation and appendation

2015-01-25 Thread WhatMeWorry via Digitalmars-d-learn
Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing expansion and reallocation of memory. But I still don't feel like I

Re: Difference between concatenation and appendation

2015-01-25 Thread 岩倉 澪
On Monday, 26 January 2015 at 01:17:17 UTC, WhatMeWorry wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing

Re: Difference between concatenation and appendation

2015-01-25 Thread bearophile via Digitalmars-d-learn
Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile

Re: Linking C library (.dll) to D on windows

2015-01-25 Thread Mike Parker via Digitalmars-d-learn
On 1/26/2015 5:45 AM, Roman wrote: Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include module.h int add(int a, int b) {return a + b;} module.h: int add(int,int); I want to use function add from D so i call cc -shared module.c -o

Re: Linking C library (.dll) to D on windows

2015-01-25 Thread Mike Parker via Digitalmars-d-learn
On 1/26/2015 11:18 AM, Mike Parker wrote: * Compile with another compiler and run implib (part of the free Basic Utilities Package from Digital Mars, downloadable from [1]) on the dll to generate an import library in OMF format. [1] http://www.digitalmars.com/download/freecompiler.html

Linking C library (.dll) to D on windows

2015-01-25 Thread Roman via Digitalmars-d-learn
Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include module.h int add(int a, int b) {return a + b;} module.h: int add(int,int); I want to use function add from D so i call cc -shared module.c -o module.dll Then D code main.d: import

Conflicts with Import error - New to D, trying to build a new project

2015-01-25 Thread Gan via Digitalmars-d-learn
Here's a screenshot: http://cl.ly/image/2n282v0B1X2M The error is: /Users/Matt/Projects/spacecraft/source/Game/Game.d(0,0): Error: class Game.Game.Game conflicts with import Game.Game.Game at source/Game/Game.d(2) (spacecraft) I figure it's because I did imports wrong or something. I'm

Re: PostgreSQL driver

2015-01-25 Thread ChrisG via Digitalmars-d-learn
So, it's been about a year since you asked this. Did you ever determine which PostgreSQL library to use? Is there one that makes any more sense than the others?

Re: using the full range of ubyte with iota

2015-01-25 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Sunday, 25 January 2015 at 18:59:04 UTC, ketmar wrote: auto x2 = (x4) | (x4); // swap nibbles - but result in an int! this is true for C and C++ too, as all three languages doing integer promotion. the only difference is that D forbids potentially lossy assigns. you best bet is to

Re: Link errors with curl, libevent, OpenSSL

2015-01-25 Thread Vladimir Panteleev via Digitalmars-d-learn
On Sunday, 25 January 2015 at 15:23:03 UTC, AndyC wrote: On Sunday, 25 January 2015 at 15:11:33 UTC, AndyC wrote: On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote: On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example:

Re: When to use typecons.proxy vs alias this?

2015-01-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 25 January 2015 at 05:57:37 UTC, weaselcat wrote: So the only difference is that proxy doesn't have implicit conversions? Hm. Might be worth pointing out on the docs. I don't think it is the *only* difference - the implementations are very different - but I do think it is the most