Re: Metaprogramming, generate argument list.

2016-08-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 22 August 2016 at 22:01:51 UTC, ciechowoj wrote: Is it possible to generate an argument list that contains pointers to local variables at compile time? For example, consider following code: template Repeat(alias int N, alias variable) { // Magic alias Repeat = /* Even more

Re: Rebind template(bug?)

2016-08-22 Thread ag0aep6g via Digitalmars-d-learn
On 08/23/2016 03:23 AM, Engine Machine wrote: On Monday, 22 August 2016 at 22:52:28 UTC, ag0aep6g wrote: [...] Simply not replying is an option, too. It may be a bit less polite, but it's better than escalating things. True, but then you should also take your own advice. Yeah, I'm going to

Re: How to avoid ctRegex (solved)

2016-08-22 Thread ag0aep6g via Digitalmars-d-learn
On 08/23/2016 06:06 AM, cy wrote: On Sunday, 21 August 2016 at 21:18:11 UTC, ag0aep6g wrote: I may be missing the point here, but just putting `auto pattern = regex("foobar");` at module level works for me. Really? I thought global variables could only be initialized with static stuff availab

Re: How to avoid ctRegex (solved)

2016-08-22 Thread cy via Digitalmars-d-learn
On Sunday, 21 August 2016 at 21:18:11 UTC, ag0aep6g wrote: I may be missing the point here, but just putting `auto pattern = regex("foobar");` at module level works for me. Really? I thought global variables could only be initialized with static stuff available during compile time, and you ne

Re: Rebind template(bug?)

2016-08-22 Thread Engine Machine via Digitalmars-d-learn
On Monday, 22 August 2016 at 22:52:28 UTC, ag0aep6g wrote: On Monday, 22 August 2016 at 21:46:35 UTC, Engine Machine wrote: I'm sorry if it confuses you... it doesn't confuse me. You needed quite some help to get this thing to work. And you made some mistakes and wrong statements in the proce

Re: Rebind template(bug?)

2016-08-22 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 22 August 2016 at 21:46:35 UTC, Engine Machine wrote: I'm sorry if it confuses you... it doesn't confuse me. You needed quite some help to get this thing to work. And you made some mistakes and wrong statements in the process. That's perfectly fine, but please don't act as if Jack

Metaprogramming, generate argument list.

2016-08-22 Thread ciechowoj via Digitalmars-d-learn
Is it possible to generate an argument list that contains pointers to local variables at compile time? For example, consider following code: template Repeat(alias int N, alias variable) { // Magic alias Repeat = /* Even more magic */; } void foo(int* x, int* y, int* z) { // [...]

Re: Rebind template(bug?)

2016-08-22 Thread Engine Machine via Digitalmars-d-learn
On Monday, 22 August 2016 at 19:09:34 UTC, Jack Applegame wrote: On Monday, 22 August 2016 at 18:04:43 UTC, Engine Machine wrote: How do you seriously think this is cleaner/simpler? 1. No extra encrypted things, such as InstantiateOrEmptySeq 2. Much more understandable. You have two classes.

Re: Creating an array of user-defined structs

2016-08-22 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 22 August 2016 at 07:00:23 UTC, brian wrote: On Monday, 22 August 2016 at 06:19:00 UTC, Mike Parker wrote: Terminology wise, we distinguish between associative arrays (AA) and arrays. The former should never simply be called 'array', otherwise people will assume you are referring to

Re: Rebind template(bug?)

2016-08-22 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 22 August 2016 at 19:56:08 UTC, ag0aep6g wrote: So this is just to avoid typing out `class Pug : Dog {...} class Dog : Animal {...} class Animal {...}`? This allows you to create different inheritance chains with the same components quickly and easily. I don't know any use case, but

Re: Rebind template(bug?)

2016-08-22 Thread ag0aep6g via Digitalmars-d-learn
On 08/22/2016 08:54 PM, Engine Machine wrote: Yeah, but a name means nothing. Change it if you want ;) Even with a better name it still requires a good amount of thinking by the reader to see what's going on. [...] What it achieves is a uniform way to create a hierarchical relationship with

Re: Rebind template(bug?)

2016-08-22 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 22 August 2016 at 18:48:12 UTC, ag0aep6g wrote: You can take this further with template constraints. Gives it a more uniform appearance at the price of some repetition: class T() { int x; } class T(A...) : T!(A[0..$-1]) if (A.length > 0 && A[$-1] == "Animal") { int

Re: Rebind template(bug?)

2016-08-22 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 22 August 2016 at 18:04:43 UTC, Engine Machine wrote: How do you seriously think this is cleaner/simpler? 1. No extra encrypted things, such as InstantiateOrEmptySeq 2. Much more understandable. You have two classes. No. I have one template with two specializations. Class template

Re: Rebind template(bug?)

2016-08-22 Thread Engine Machine via Digitalmars-d-learn
On Monday, 22 August 2016 at 18:48:12 UTC, ag0aep6g wrote: On 08/22/2016 08:04 PM, Engine Machine wrote: How do you seriously think this is cleaner/simpler? You have two classes. Their is no uniformity between them. You have uniformity between all the derived classes then have a special case fo

Re: Rebind template(bug?)

2016-08-22 Thread ag0aep6g via Digitalmars-d-learn
On 08/22/2016 08:04 PM, Engine Machine wrote: How do you seriously think this is cleaner/simpler? You have two classes. Their is no uniformity between them. You have uniformity between all the derived classes then have a special case for the base class. A certain easy to follow pattern is set up

Re: Float values are wrong in union

2016-08-22 Thread Engine Machine via Digitalmars-d-learn
On Monday, 22 August 2016 at 05:02:41 UTC, jkpl wrote: On Monday, 22 August 2016 at 04:52:40 UTC, Cauterite wrote: [...] That's a 32 bit codegen issue then because DMD64 's disasm shows that SSE regs are used: void foo() { union test { int i; float f; } test t = { i : 0x7fb

Re: Rebind template(bug?)

2016-08-22 Thread Engine Machine via Digitalmars-d-learn
On Monday, 22 August 2016 at 07:54:36 UTC, Jack Applegame wrote: On Monday, 22 August 2016 at 00:43:00 UTC, Engine Machine wrote: The following code works and does what I want! template InstantiateOrEmptySeq(alias tmpl, args...) { alias Seq(T...)=T; static if (args.length > 0) a

Re: __traits(getOverloads, Type, member) order of elements in tuple.

2016-08-22 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 22 August 2016 at 12:14:41 UTC, Alexandru Ermicioi wrote: Good day. In current implementation of dmd/ldc/gdc, does this trait guarantee, that the order of elements returned in tuple, is same, in several calls of it on same Type and member? Also, is guaranteed that in future versio

__traits(getOverloads, Type, member) order of elements in tuple.

2016-08-22 Thread Alexandru Ermicioi via Digitalmars-d-learn
Good day. In current implementation of dmd/ldc/gdc, does this trait guarantee, that the order of elements returned in tuple, is same, in several calls of it on same Type and member? Also, is guaranteed that in future versions of dmd, the order of elements won't change?

Re: Get current date and time with std.datetime

2016-08-22 Thread Joel via Digitalmars-d-learn
On Friday, 1 July 2016 at 15:28:04 UTC, Zekereth wrote: On Thursday, 30 June 2016 at 21:18:22 UTC, Luke Picardo wrote: Why is it so hard to simply get the current date and time formatted properly in a string? There are no examples of this in your documentation yet this is probably one of th

Re: Creating an array of user-defined structs

2016-08-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 22 August 2016 at 07:00:23 UTC, brian wrote: That's a terribly confusing naming convention for beginners then! :P Is this D-specific terminology, or is this a more general convention that AA are not actually arrays? This might help my understanding of when to use or not use one or

Re: Rebind template(bug?)

2016-08-22 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 22 August 2016 at 00:43:00 UTC, Engine Machine wrote: The following code works and does what I want! template InstantiateOrEmptySeq(alias tmpl, args...) { alias Seq(T...)=T; static if (args.length > 0) alias InstantiateOrEmptySeq = tmpl!(args[0 .. $-1]); else

Re: Creating an array of user-defined structs

2016-08-22 Thread brian via Digitalmars-d-learn
On Monday, 22 August 2016 at 06:19:00 UTC, Mike Parker wrote: Terminology wise, we distinguish between associative arrays (AA) and arrays. The former should never simply be called 'array', otherwise people will assume you are referring to either or both of foo[] (dynamic array/slice) or foo[N]