Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: import std.traits: Parameters; auto mySpawn(F)(F func, Parameters!F params) { static auto callIt(F func, Parameters!F params) { try { return func(params); }

Re: exercise - find invalid D tokens (Impossible ?)

2016-10-27 Thread Basile B. via Digitalmars-d-learn
On Friday, 28 October 2016 at 06:21:38 UTC, Johan Engelen wrote: On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote: Here are the specifications of token strings: "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }" S

Re: exercise - find invalid D tokens (Impossible ?)

2016-10-27 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote: Here are the specifications of token strings: "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }" So we can deduce that any invalid D token inside a token string wi

exercise - find invalid D tokens (Impossible ?)

2016-10-27 Thread Basile B. via Digitalmars-d-learn
Here are the specifications of token strings: "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }" So we can deduce that any invalid D token inside a token string will lead to a compilation error. Indeed: void main() { en

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
I found http://arsdnet.net/this-week-in-d/2016-aug-07.html Maybe it's helps me.

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Friday, 28 October 2016 at 03:38:05 UTC, dm wrote: On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: ... Main thread still running. Actually it's depends on compiler. With ldc2 main thread doesn't stop, but with dmd seems all ok: root@proxytest:~#

Re: test if the alias of a template is a literal

2016-10-27 Thread Basile B. via Digitalmars-d-learn
On Friday, 28 October 2016 at 03:33:33 UTC, Basile B. wrote: On Thursday, 27 October 2016 at 14:04:23 UTC, Gianni Pisetta wrote: So i searched for a metod to check if an alias is a literal value, but found nothing. Anyone have any clue on how can be done? Thanks, Gianni Pisetta Hello, I thi

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread dm via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:37:29 UTC, Steven Schveighoffer wrote: Hm... what about: ... Main thread still running.

Re: test if the alias of a template is a literal

2016-10-27 Thread Basile B. via Digitalmars-d-learn
On Thursday, 27 October 2016 at 14:04:23 UTC, Gianni Pisetta wrote: Hi all, I have an AliasSeq composed of literal strings, variables and delegates. I want to build a template Optimize that will return an AliasSeq that have all adjacent literals concatenated into one. So i writed something lik

Re: A question of function design?

2016-10-27 Thread pineapple via Digitalmars-d-learn
On Thursday, 27 October 2016 at 22:17:35 UTC, WhatMeWorry wrote: I'm using Derelict GLFW3 and I found the following GLFW3 code snippet in a demo. In a small demo, crap like this usually isn't a big deal. It's not common practice, though, and for good reason. You should definitely avoid imit

A question of function design?

2016-10-27 Thread WhatMeWorry via Digitalmars-d-learn
I'm using Derelict GLFW3 and I found the following GLFW3 code snippet in a demo. float distance = 3.0; extern(C) void key_callback(GLFWwindow* window, int key, int scancode, int action, int modifier) nothrow { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { glfwSetWin

Re: New to D

2016-10-27 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:43:26 UTC, Steven Schveighoffer wrote: It depends on the size of the file and the expectation of duplicate words. I'm assuming the number of words is limited, so you are going to allocate far less data by duping on demand. In addition, you may incur penalties

Re: Map type to class instance at compile-time

2016-10-27 Thread Ali Çehreli via Digitalmars-d-learn
I admit that I can't come up with a solution right now. I hope others can see a way out of what I describe below. :-/ On 10/27/2016 11:33 AM, pontius wrote: > On Wednesday, 26 October 2016 at 18:19:33 UTC, Ali Çehreli wrote: >> There are different approaches but I think the solution above achi

Re: MongoDB/DB <-> D

2016-10-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne 27.10.2016 v 20:54 Jot via Digitalmars-d-learn napsal(a): Using Vibe.D here; How can one work with the DB's abstractly without incurring duplicity. I'd like to be able to create one struct and use that, either in D or the DB. I'd prefer to create a struct in D and interact through that s

MongoDB/DB <-> D

2016-10-27 Thread Jot via Digitalmars-d-learn
Using Vibe.D here; How can one work with the DB's abstractly without incurring duplicity. I'd like to be able to create one struct and use that, either in D or the DB. I'd prefer to create a struct in D and interact through that struct with the database abstracted away. struct Person { s

Re: What is the difference between pages under dlang.org/phobos and dlang.org/library?

2016-10-27 Thread A D dev via Digitalmars-d-learn
On Thursday, 27 October 2016 at 18:47:07 UTC, Adam D. Ruppe wrote: It is the same content, generated at the same time, just laid out differently. You can use whichever you find easier. Thanks, Adam.

Re: What is the difference between pages under dlang.org/phobos and dlang.org/library?

2016-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 October 2016 at 18:44:00 UTC, A D dev wrote: I viewed the above two pages and the content seems roughly the same. It is the same content, generated at the same time, just laid out differently. You can use whichever you find easier.

What is the difference between pages under dlang.org/phobos and dlang.org/library?

2016-10-27 Thread A D dev via Digitalmars-d-learn
Hi list, What is the difference between pages under dlang.org/phobos and dlang.org/library? And when should we use which, as a reference? E.g. https://dlang.org/phobos/std_zip.html https://dlang.org/library/std/zip.html I viewed the above two pages and the content seems roughly the same. H

Re: Map type to class instance at compile-time

2016-10-27 Thread pontius via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 18:19:33 UTC, Ali Çehreli wrote: There are different approaches but I think the solution above achieves what you want: DefaultManager!(A) is managing an object of A DefaultManager!(B) is managing an object of B SomeCustomManager is managing an object of C Ali

Re: Address of an array

2016-10-27 Thread David via Digitalmars-d-learn
A dynamic array looks something kind of like this: struct DynamicArray(T) { size_t length; T* ptr; } So, if you take the address of a dynamic array, you're basically taking the address of a struct on the stack, whereas the address in ptr is the address in memory where the data is (be

Re: Address of an array

2016-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 27, 2016 16:13:34 David via Digitalmars-d-learn wrote: > Hi > > The pointer (.ptr) of an array is the address of the first array > element. But what exactly is the address of the array? And how is > it used? > >auto myArray = [5, 10, 15, 20, 25, 30, 35]; >writeln("myArr

Re: Address of an array

2016-10-27 Thread David via Digitalmars-d-learn
On Thursday, 27 October 2016 at 16:13:34 UTC, David wrote: Hi The pointer (.ptr) of an array is the address of the first array element. But what exactly is the address of the array? And how is it used? auto myArray = [5, 10, 15, 20, 25, 30, 35]; writeln("myArray.ptr: ", myArray.ptr); //

Address of an array

2016-10-27 Thread David via Digitalmars-d-learn
Hi The pointer (.ptr) of an array is the address of the first array element. But what exactly is the address of the array? And how is it used? auto myArray = [5, 10, 15, 20, 25, 30, 35]; writeln("myArray.ptr: ", myArray.ptr); // myArray.ptr: 7FFA95F29000 writeln("&myArray[0]: ", &myArr

Re: test if the alias of a template is a literal

2016-10-27 Thread TheFlyingFiddle via Digitalmars-d-learn
On Thursday, 27 October 2016 at 14:45:22 UTC, Gianni Pisetta wrote: On Thursday, 27 October 2016 at 14:34:38 UTC, TheFlyingFiddle wrote: On Thursday, 27 October 2016 at 14:04:23 UTC, Gianni Pisetta wrote: Hi all, but at the moment isStringLiteral will return true even with variables of type st

Re: test if the alias of a template is a literal

2016-10-27 Thread Gianni Pisetta via Digitalmars-d-learn
On Thursday, 27 October 2016 at 14:34:38 UTC, TheFlyingFiddle wrote: On Thursday, 27 October 2016 at 14:04:23 UTC, Gianni Pisetta wrote: Hi all, but at the moment isStringLiteral will return true even with variables of type string. So i searched for a metod to check if an alias is a literal va

Re: test if the alias of a template is a literal

2016-10-27 Thread TheFlyingFiddle via Digitalmars-d-learn
On Thursday, 27 October 2016 at 14:04:23 UTC, Gianni Pisetta wrote: Hi all, but at the moment isStringLiteral will return true even with variables of type string. So i searched for a metod to check if an alias is a literal value, but found nothing. Anyone have any clue on how can be done? Th

test if the alias of a template is a literal

2016-10-27 Thread Gianni Pisetta via Digitalmars-d-learn
Hi all, I have an AliasSeq composed of literal strings, variables and delegates. I want to build a template Optimize that will return an AliasSeq that have all adjacent literals concatenated into one. So i writed something like this: template isStringLiteral(alias V) { enum bool isStringL

Re: New to D

2016-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/27/16 2:40 AM, Era Scarecrow wrote: On Tuesday, 25 October 2016 at 14:40:17 UTC, Steven Schveighoffer wrote: I will note, that in addition to the other comments, this is going to result in corruption. Simply put, the buffer that 'line' uses is reused for each line. So the string data used

Re: How to kill whole application if child thread raises an exception?

2016-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/16 4:42 AM, dm wrote: Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(&func); foreach(line; stdin.byLine) send(tID, ""); } I expect my application will die im

Re: No trace of cumulativeFold except in the source.

2016-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 23, 2016 19:20:43 e-y-e via Digitalmars-d-learn wrote: > On this topic, do you think a 'cumulativeSum' specialisation > based on the 'sum' specialisation be welcome in phobos? Here's a > quick prototype, obviously not library standard but the basic > logic is there: > https://gis

Re: Avoiding GC

2016-10-27 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? The information is scattered. How do I allocate / free structs / classes on the heap manually? Classes => https://github.com/AuburnSounds/dplug/blob/master/c