Re: C header file: tagged enumerations

2016-04-27 Thread BLM768 via Digitalmars-d-learn
On Tuesday, 26 April 2016 at 23:40:24 UTC, Adam D. Ruppe wrote: D doesn't handle this C pattern well... you basically have to rewrite the whole thing for each version. Or you can use the technique that's used in llvm-d: build the enumeration from a string mixin which is generated from a

Re: C header file: tagged enumerations

2016-04-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/26/16 7:40 PM, Adam D. Ruppe wrote: On Tuesday, 26 April 2016 at 23:33:08 UTC, Stefan Koch wrote: static if (win32msi >= 500) . Won't work here because static if must have a complete declaration inside it, and the C pattern only has a few elements of the whole inside each #if. D

Re: vibe.d is blocking threads

2016-04-27 Thread yawniek via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 13:00:29 UTC, RuZzz wrote: Code: import std.concurrency; import core.thread; //import vibe.http.client; // If uncommented this line, the thread "worker" does not start void worker() { foreach (i; 0 .. 5) {

Re: C header file: tagged enumerations

2016-04-27 Thread Max Samukha via Digitalmars-d-learn
On Tuesday, 26 April 2016 at 22:57:36 UTC, Jesse Phillips wrote: typedef enum tagINSTALLMESSAGE { // 12 others ... INSTALLMESSAGE_INITIALIZE , INSTALLMESSAGE_TERMINATE , INSTALLMESSAGE_SHOWDIALOG , #if (_WIN32_MSI >= 500) INSTALLMESSAGE_PERFORMANCE

Re: What does alias do?

2016-04-27 Thread xtreak via Digitalmars-d-learn
On Saturday, 23 April 2016 at 20:01:00 UTC, ag0aep6g wrote: On 23.04.2016 21:49, xtreak wrote: I am a D newbie from Python and I am trying to grok alias. Is alias like Python does as below L = [] myextend = L.extend L.myextend My Python isn't too great, but I think this is more similar to

Re: What does alias do?

2016-04-27 Thread ag0aep6g via Digitalmars-d-learn
On 27.04.2016 21:40, xtreak wrote: import std.array; import std.range; import std.algorithm; import std.stdio; T test(alias f, T)(T num) { return f(num); } T test1(T, V)(T num, V f){ return f(num); } void main() { writeln("hello world"); writeln(1.iota .map!(a =>

Re: Constructing an enum using the members of an AliasSeq as enumerator names

2016-04-27 Thread ag0aep6g via Digitalmars-d-learn
On 27.04.2016 13:06, Nordlöw wrote: /** Returns: a `string` containing the definition of an `enum` named `name` and with enumerator names given by `Es`, optionally prepended with `prefix` and appended with `suffix`. TODO Move to Phobos std.typecons */ string

Re: vibe.d is blocking threads

2016-04-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 13:00:29 UTC, RuZzz wrote: Code: import std.concurrency; import core.thread; //import vibe.http.client; // If uncommented this line, the thread "worker" does not start void worker() { foreach (i; 0 .. 5) {

Re: Compare lambda expressions

2016-04-27 Thread cym13 via Digitalmars-d-learn
On Tuesday, 26 April 2016 at 14:32:59 UTC, Alex wrote: Hi all! Not sure, if this belongs directly to the D language, or it is rather maths, but: given to delegate generating functions and a main auto func1(int arg) { bool delegate(int x) dg; dg = (x) => arg * x; return dg; }

Re: Compare lambda expressions

2016-04-27 Thread Alex via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 06:59:22 UTC, cym13 wrote: On Tuesday, 26 April 2016 at 14:32:59 UTC, Alex wrote: IMHO, if you are to parse them from strings then you need a parser in order to build an abstract tree, a simpler intermediary language to restrict the possible patterns expressing

Re: Constructing an enum using the members of an AliasSeq as enumerator names

2016-04-27 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 10:49:54 UTC, Nordlöw wrote: What's the easiest way to create an `enum` using the symbol names of an `AliasSeq` as enumerator names? /** Returns: a `string` containing the definition of an `enum` named `name` and with enumerator names given by `Es`,

Constructing an enum using the members of an AliasSeq as enumerator names

2016-04-27 Thread Nordlöw via Digitalmars-d-learn
What's the easiest way to create an `enum` using the symbol names of an `AliasSeq` as enumerator names? That is, given alias Types = AliasSeq!(byte, short, int); we need some compile-time type-constructor `makeEnum` called as alias E = makeEnum!Types; that should be equivalent to

Re: DlangUI MouseEvent mouse delta

2016-04-27 Thread Vadim Lopatin via Digitalmars-d-learn
On Wednesday, 27 April 2016 at 00:15:46 UTC, stunaep wrote: I am currently handling it like this: current = e.pos(); xdelta = current.x - previous.x; ydelta = current.y - previous.y; previous = current; I'm just wondering if there is a built in solution that I missed. There is only

vibe.d is blocking threads

2016-04-27 Thread RuZzz via Digitalmars-d-learn
Code: import std.concurrency; import core.thread; //import vibe.http.client; // If uncommented this line, the thread "worker" does not start void worker() { foreach (i; 0 .. 5) { Thread.sleep(500.msecs); writeln(i, " (worker)"); }