VisualD core.exception.RangeError@pipedmd(286): Range violation

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
I get "core.exception.RangeError@pipedmd(286): Range violation" whenever I try to build from visual D. Is there any workaround for this? It was reported[1] almost 9 months ago, does not seem like it's going to be fixed anytime soon. Visual D is completely broken for me right now because of

Re: Unicode function name? ∩

2016-09-05 Thread Illuminati via Digitalmars-d-learn
On Monday, 29 August 2016 at 12:53:26 UTC, Jesper Tholstrup wrote: On Sunday, 28 August 2016 at 05:21:03 UTC, Tofu Ninja wrote: Are unicode function names not supported in dmd? bool ∩(A, B)(A a, B b){ return intersect(a, b); } Error: character 0x2229 is not a valid token Personally,

Re: dependency analysis for makefile construction

2016-09-05 Thread dan via Digitalmars-d-learn
On Monday, 5 September 2016 at 18:49:25 UTC, Basile B. wrote: On Monday, 5 September 2016 at 18:22:08 UTC, ag0aep6g wrote: On 09/04/2016 12:07 AM, dan wrote: Are there any FOSS tools for doing dependency analysis of [...] [...] I'm not aware of a standalone tool that does something like

Re: Removing array element in foreach, safe?

2016-09-05 Thread dom via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:38:10 UTC, Daniel Kozak wrote: On Monday, 5 September 2016 at 15:53:39 UTC, dom wrote: is this code safe? if not how do i do it correctly? static AsyncHttpGet[] openRequests; static void updateRequests() { foreach(idx,

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 19:03:00 UTC, Tofu Ninja wrote: On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I am not sure what changed but I can no longer build using visuald after generating from dub. When I try to build from visual studio I get the following error LINK :

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I am not sure what changed but I can no longer build using visuald after generating from dub. When I try to build from visual studio I get the following error LINK : warning LNK4001: no object files specified; libraries used

Re: dependency analysis for makefile construction

2016-09-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 September 2016 at 18:22:08 UTC, ag0aep6g wrote: On 09/04/2016 12:07 AM, dan wrote: Are there any FOSS tools for doing dependency analysis of [...] [...] I'm not aware of a standalone tool that does something like this. If you want to write one, you could do like rdmd and use

Re: dub generate visuald

2016-09-05 Thread Tofu Ninja via Digitalmars-d-learn
On Monday, 5 September 2016 at 18:22:02 UTC, Guillaume Piolat wrote: On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I can build directly from dub with no problem, but building from VS gives that error. Building with dub uses the dmd settings in sc.ini Building with VisualD

Re: dependency analysis for makefile construction

2016-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/04/2016 12:07 AM, dan wrote: Are there any FOSS tools for doing dependency analysis of (e.g.) all the d files in a directory, to let you know when a .o file needs to be regenerated? This presumably would depend mostly on the import statements (including import of any file to be used in

Re: dub generate visuald

2016-09-05 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:25:45 UTC, Tofu Ninja wrote: I can build directly from dub with no problem, but building from VS gives that error. Building with dub uses the dmd settings in sc.ini Building with VisualD can override those settings.

Re: Inexplicable invalid memory operation when program terminates

2016-09-05 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 05, 2016 at 05:48:11PM +, pineapple via Digitalmars-d-learn wrote: [...] > In the example the window class destructor was being called. I found > that if I did `delete win;` at the end there it worked fine, but > otherwise the GC was tripping up? I removed a console output

Re: Inexplicable invalid memory operation when program terminates

2016-09-05 Thread pineapple via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:33:17 UTC, pineapple wrote: Am I missing something or is this an obnoxious bug with the GC? Oh, I've been trying to figure this out on and off for days and of course five minutes after I post I fix the problem. I'm not really sure why, but it did fix it.

Re: Inexplicable invalid memory operation when program terminates

2016-09-05 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 05, 2016 at 05:33:17PM +, pineapple via Digitalmars-d-learn wrote: > I have a program which I have stripped down to a single offending line > which, when present in my program, causes an invalid memory operation > to occur after main has evaluated: > > import mach.sdl.window;

Re: Inexplicable invalid memory operation when program terminates

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:33:17 UTC, pineapple wrote: I have a program which I have stripped down to a single offending line which, when present in my program, causes an invalid memory operation to occur after main has evaluated: import mach.sdl.window; void main(){

Re: Removing array element in foreach, safe?

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 5 September 2016 at 17:38:10 UTC, Daniel Kozak wrote: On Monday, 5 September 2016 at 15:53:39 UTC, dom wrote: is this code safe? if not how do i do it correctly? static AsyncHttpGet[] openRequests; static void updateRequests() { foreach(idx,

Re: Removing array element in foreach, safe?

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 5 September 2016 at 15:53:39 UTC, dom wrote: is this code safe? if not how do i do it correctly? static AsyncHttpGet[] openRequests; static void updateRequests() { foreach(idx, req; openRequests) {

Re: Getting the superclass of a type?

2016-09-05 Thread pineapple via Digitalmars-d-learn
On Monday, 5 September 2016 at 15:43:52 UTC, Lodovico Giaretta wrote: On Monday, 5 September 2016 at 15:20:10 UTC, pineapple wrote: I'd like to be able to write something like this, but I haven't been able to find anything in the docs class Base{} class Sub: Base{} static

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:32:49 UTC, Lodovico Giaretta wrote: On Monday, 5 September 2016 at 12:15:35 UTC, dom wrote: [...] You misunderstood the error message and the lambda syntax (it also happened to me the first time). The grammar says that you can use one of these syntaxes:

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:30:37 UTC, Daniel Kozak wrote: Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes,

Re: Getting the superclass of a type?

2016-09-05 Thread Johannes Loher via Digitalmars-d-learn
Am 05.09.2016 um 17:43 schrieb Lodovico Giaretta: > On Monday, 5 September 2016 at 15:20:10 UTC, pineapple wrote: >> I'd like to be able to write something like this, but I haven't been >> able to find anything in the docs >> >> class Base{} >> class Sub: Base{} >> static

Removing array element in foreach, safe?

2016-09-05 Thread dom via Digitalmars-d-learn
is this code safe? if not how do i do it correctly? static AsyncHttpGet[] openRequests; static void updateRequests() { foreach(idx, req; openRequests) { if(req.state != Fiber.State.TERM)

Re: Getting the superclass of a type?

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 15:20:10 UTC, pineapple wrote: I'd like to be able to write something like this, but I haven't been able to find anything in the docs class Base{} class Sub: Base{} static assert(is(SuperClassOf!Sub == Base));

Getting the superclass of a type?

2016-09-05 Thread pineapple via Digitalmars-d-learn
I'd like to be able to write something like this, but I haven't been able to find anything in the docs class Base{} class Sub: Base{} static assert(is(SuperClassOf!Sub == Base));

Re: Assign any event kind to a single templatized function ?

2016-09-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 September 2016 at 14:00:04 UTC, ag0aep6g wrote: On 09/05/2016 03:44 PM, Basile B. wrote: [...] You can pass the delegate type itself by alias. Then Parameters carries over the ref. Not sure if that's well-defined or if it just happens to work. void

Re: Assign any event kind to a single templatized function ?

2016-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/05/2016 04:00 PM, ag0aep6g wrote: You can pass the delegate type itself by alias. [...] void handlef(F)(Parameters!F a){writeln(a);} Don't know why I wrote "by alias". Clearly no alias there.

Re: Assign any event kind to a single templatized function ?

2016-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/05/2016 03:44 PM, Basile B. wrote: °° module runnable; import std.stdio; struct Foo { void delegate(int) event1; void delegate(int,int) event2; void delegate(int,ref int) event3; } struct Handler { void handle(A...)(A a){writeln(a);} void

Re: Assign any event kind to a single templatized function ?

2016-09-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 September 2016 at 13:44:53 UTC, Basile B. wrote: Typo, last line should be: foo.event3 = !(Parameters!(foo.event3)); But it still doesnt work.

Assign any event kind to a single templatized function ?

2016-09-05 Thread Basile B. via Digitalmars-d-learn
It's almost a "yeah". However this doesn't work with ref parameters. Any idea how to make this work, keeping the simplicity of the concept ? °° module runnable; import std.stdio; struct Foo { void delegate(int) event1; void delegate(int,int) event2;

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:15:35 UTC, dom wrote: [...] You misunderstood the error message and the lambda syntax (it also happened to me the first time). The grammar says that you can use one of these syntaxes: 1) `(arguments) {block of code}` 2) `(arguments) => expression`, which

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:30 Daniel Kozak napsal(a): Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes, RTFM :) But to be

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes, RTFM :)

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): I am about to write my own stupid and simple http client .. and i have added a callback function that has the received content as a parameter. class AsyncHttpGet { this(string host, ushort port, string path, void delegate(string)

delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
I am about to write my own stupid and simple http client .. and i have added a callback function that has the received content as a parameter. class AsyncHttpGet { this(string host, ushort port, string path, void delegate(string) callback ) { ... } } My first attempt was to write:

Re: Custom String vs D String performance

2016-09-05 Thread Patric via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:03:49 UTC, Patric wrote: On Monday, 5 September 2016 at 11:53:12 UTC, Daniel Kozak wrote: Do you have windows or linux? Which version of dmd you have? Now on my job pc: DMD32 D Compiler v2.071.0-b2 In home i have 64 last version, and with my first version it

Re: Custom String vs D String performance

2016-09-05 Thread Patric via Digitalmars-d-learn
On Monday, 5 September 2016 at 11:55:09 UTC, rikki cattermole wrote: Be a bit careful there, when a struct is moved around its destructor will be called. This is why I suggested you to use the GC to allocate memory or else ouch. So you'll find very quickly that you will be having segfaults

Re: Custom String vs D String performance

2016-09-05 Thread Patric via Digitalmars-d-learn
On Monday, 5 September 2016 at 11:53:12 UTC, Daniel Kozak wrote: Do you have windows or linux? Which version of dmd you have? Now on my job pc: DMD32 D Compiler v2.071.0-b2 In home i have 64 last version, and with my first version it shows the DString faster than my custom.

Re: Custom String vs D String performance

2016-09-05 Thread rikki cattermole via Digitalmars-d-learn
On 05/09/2016 11:45 PM, Patric wrote: On Monday, 5 September 2016 at 11:20:08 UTC, rikki cattermole wrote: On 05/09/2016 11:11 PM, Patric wrote: I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case i´m unable to get near D

Re: Custom String vs D String performance

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 13:45 Patric via Digitalmars-d-learn napsal(a): On Monday, 5 September 2016 at 11:20:08 UTC, rikki cattermole wrote: On 05/09/2016 11:11 PM, Patric wrote: I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case

Re: Custom String vs D String performance

2016-09-05 Thread Patric via Digitalmars-d-learn
On Monday, 5 September 2016 at 11:20:08 UTC, rikki cattermole wrote: On 05/09/2016 11:11 PM, Patric wrote: I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case i´m unable to get near D performance. Can someone point me out

Re: Custom String vs D String performance

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 13:17 Daniel Kozak napsal(a): Dne 5.9.2016 v 13:11 Patric via Digitalmars-d-learn napsal(a): I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case i´m unable to get near D performance. Can someone point me

Re: Custom String vs D String performance

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 13:11 Patric via Digitalmars-d-learn napsal(a): I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case i´m unable to get near D performance. Can someone point me out what i´m doing wrong, or if there is some

Custom String vs D String performance

2016-09-05 Thread Patric via Digitalmars-d-learn
I´m playing remaking D functionalities with nogc structs, and to at least match D performance. But in this particular case i´m unable to get near D performance. Can someone point me out what i´m doing wrong, or if there is some magic behind the curtains on D strings?

Re: Using OpenGL

2016-09-05 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 5 September 2016 at 05:14:56 UTC, Nicholas Wilson wrote: On Saturday, 3 September 2016 at 17:13:49 UTC, Darren wrote: Now I wonder if I can load shaders from separate files (à la http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/). see:

Re: How it's better to store data from DB?

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 10:00:26 UTC, Suliman wrote: Usually I am storing daba from DB as array of structures. Something like: struct MyData { int id; string name; int age; } MyData mydata; Then I am creating array of structures: MyData [] mydatas; And fill data in my code. Then

How it's better to store data from DB?

2016-09-05 Thread Suliman via Digitalmars-d-learn
Usually I am storing daba from DB as array of structures. Something like: struct MyData { int id; string name; int age; } MyData mydata; Then I am creating array of structures: MyData [] mydatas; And fill data in my code. Then append it to `mydatas` to get it iterable. But is it's

Re: Template-style polymorphism in table structure

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 06:45:07 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type:

Re: Template-style polymorphism in table structure

2016-09-05 Thread data pulverizer via Digitalmars-d-learn
On Monday, 5 September 2016 at 06:45:07 UTC, data pulverizer wrote: On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type:

Re: Template-style polymorphism in table structure

2016-09-05 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote: Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type: GenericVector!T getCol!T(size_t i) { if(typeid(cols[i]) ==