Re: Probably a real simple compile-time reflection question?

2016-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 July 2016 at 21:12:24 UTC, WhatMeWorry wrote: foreach( i, str; myClassMembers) What are you doing to get myClassMembers? If it is __traits(allMembers), it just gives you the *names* of the members. To get the actual thing, you then do __traits(getMember, object, str) and can

Probably a real simple compile-time reflection question?

2016-07-09 Thread WhatMeWorry via Digitalmars-d-learn
class C { this(){ _i = 0; _j = 0; } void setVar(int i) { _i = i; } int getVar() { return _i; } int _i; int _j; } writeln("C"); foreach( i, str; myClassMembers) { writeln("member ", i, " = ", str); TypeInfo ti = typeid(str); writeln("type id is ", ti);

Re: Accessing contents of associative arrays in an optimal way

2016-07-09 Thread phant0m via Digitalmars-d-learn
Thank you!

Re: Accessing contents of associative arrays in an optimal way

2016-07-09 Thread ag0aep6g via Digitalmars-d-learn
On 07/09/2016 10:32 PM, phant0m wrote: As far as I know, AA implemented as a hashtable. So, will there be two searches performed (one search for each line)? records[3].value = 10; records[3].name = "name"; Yup. A good optimizer may be able to eliminate one, but conceptually there are two

Re: Singleton Pattern

2016-07-09 Thread Ali Çehreli via Digitalmars-d-learn
On 07/09/2016 01:35 PM, Suliman wrote: > On Thursday, 5 January 2012 at 22:53:12 UTC, Ali Çehreli wrote: >> On 01/05/2012 02:15 PM, asm wrote: >>> how can i implementing the singleton pattern in D? >> >> Is singleton still alive? ;) I'm glad I was alive in 2012. :o) >> An idea is to instantiate

Re: Accessing contents of associative arrays in an optimal way

2016-07-09 Thread Ali Çehreli via Digitalmars-d-learn
On 07/09/2016 01:32 PM, phant0m wrote: > Suppose I have AA of structures: > > struct Foo { > int value; > string name; > } > > Foo[int] records; > > As far as I know, AA implemented as a hashtable. So, will there be two > searches performed (one search for each line)? > records[3].value

Re: Singleton Pattern

2016-07-09 Thread Suliman via Digitalmars-d-learn
On Thursday, 5 January 2012 at 22:53:12 UTC, Ali Çehreli wrote: On 01/05/2012 02:15 PM, asm wrote: how can i implementing the singleton pattern in D? Is singleton still alive? ;) An idea is to instantiate the object in the module's static this(). Ali Yeah, same question, what difference

Accessing contents of associative arrays in an optimal way

2016-07-09 Thread phant0m via Digitalmars-d-learn
Suppose I have AA of structures: struct Foo { int value; string name; } Foo[int] records; As far as I know, AA implemented as a hashtable. So, will there be two searches performed (one search for each line)? records[3].value = 10; records[3].name = "name"; How can I access elements

Re: Variadic Tuple of Structs with Mixed Types

2016-07-09 Thread jmh530 via Digitalmars-d-learn
On Saturday, 9 July 2016 at 05:40:10 UTC, ag0aep6g wrote: template bar(T, U...) if (U.length > 1) { import std.meta : staticMap; import std.typecons : Tuple; alias baz(A) = Tuple!(T, A); alias V = staticMap!(baz, U); alias TupleToFoo(T : Tuple!(Types), Types ...) =

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 09, 2016 at 11:57:36PM +1200, rikki cattermole via Digitalmars-d-learn wrote: > On 09/07/2016 11:46 PM, Tofu Ninja wrote: > > On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote: > > > On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: > > > > On Saturday, 9 July 2016 at

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:57:36 UTC, rikki cattermole wrote: That implementation is weird in that it returns a dchar instead of the raw type. Which is decoding, but it is not auto decoding. Auto decoding involves the foreach statement. You have that backwards. foreach only decodes if you

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread ketmar via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:57:36 UTC, rikki cattermole wrote: In this case, its not aut odecoding. ElementType is using std.range : front for array's since they do not provide a front method. That implementation is weird in that it returns a dchar hello, autodecoding.

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:46:14 UTC, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/07/2016 11:46 PM, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding.

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:35:24 UTC, Tofu Ninja wrote: On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding. Hmmm... I dont really know the history of

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:29:18 UTC, ketmar wrote: On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding. Hmmm... I dont really know the history of autodecoding, why was that supposed to be a good idea?

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread ketmar via Digitalmars-d-learn
On Saturday, 9 July 2016 at 11:24:01 UTC, Tofu Ninja wrote: Seems pretty silly to me... due to universally beloved autodecoding.

Re: Why is ElementType!(char[]) == dchar?

2016-07-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/07/2016 11:24 PM, Tofu Ninja wrote: Seems pretty silly to me... http://dlang.org/phobos/std_range_primitives.html#.front

Why is ElementType!(char[]) == dchar?

2016-07-09 Thread Tofu Ninja via Digitalmars-d-learn
Seems pretty silly to me...

Re: Dub recursive build and forcing pre-build commands to run

2016-07-09 Thread Antonio Corbi via Digitalmars-d-learn
On Saturday, 9 July 2016 at 00:03:22 UTC, Meta wrote: I have two questions. 1. Is it possible to build subpackages when dub build is invoked for the main package? It's a pain to first do dub build :mysubpackage and then dub build. 2. It seems that when dub detects that no dependencies need