Re: Figuring out the returntype opDipatch

2013-11-02 Thread TheFlyingFiddle
struct S { R opDispatch(string name, R, T...)(T parameters) { return R.init; } } void main() { auto s = S(); auto r0 = s.foo!("foo", int)("hello");// does not compile auto r1 = s.bar!("bar", double)(100); static assert (is (typeof(r0) == int)); stat

Re: Figuring out the returntype opDipatch

2013-11-02 Thread Ali Çehreli
On 11/02/2013 03:41 PM, TheFlyingFiddle wrote: > The problem i am faced with is that i need a way to figure out the > return value of opDispatch by the invokation call. If I now understand you correctly, what initially confused my was "invocation call." Because "invocation" makes me think about

Re: Figuring out the returntype opDipatch

2013-11-02 Thread TheFlyingFiddle
Can you provide a little more complete code please. Otherwise, the return type is available to typeof: import std.stdio; struct S { auto opDispatch(string name, T...)(T parameters) { writef("S.%s:", name); foreach (parameter; parameters) { writef(" %s", param

Re: Figuring out the returntype opDipatch

2013-11-02 Thread Ali Çehreli
On 11/02/2013 03:41 PM, TheFlyingFiddle wrote: I'm currently working on a IReflectionable interface Currently the usage is as follows class Foo : IReflectionable { mixin ReflectionImpl; void bar(int a) { /* do something */ } int baz(string a) { return a.length; } } unittest { IR

Re: Associative Array: reasonable limits?

2013-11-02 Thread TheFlyingFiddle
If AAs don't have any hidden penalty, like causing the garbage collector to thrash, then that's the way to go Any time you insert an item into an AA it might allocate. So it might cause a garbage collection cycle. I'm unsure what you mean by "causing the garbage collector to trash" memory leea

Re: Associative Array: reasonable limits?

2013-11-02 Thread Charles Hixson
On 11/02/2013 05:16 PM, TheFlyingFiddle wrote: On Saturday, 2 November 2013 at 23:58:07 UTC, Charles Hixson wrote: On 11/02/2013 04:49 PM, TheFlyingFiddle wrote: What are you going to be using the collection for? It's basically a lookup table used for translating external codes (essentially

Re: Associative Array: reasonable limits?

2013-11-02 Thread TheFlyingFiddle
On Saturday, 2 November 2013 at 23:58:07 UTC, Charles Hixson wrote: On 11/02/2013 04:49 PM, TheFlyingFiddle wrote: What are you going to be using the collection for? It's basically a lookup table used for translating external codes (essentially arbitrary) into id#s used internally. There ar

Re: Associative Array: reasonable limits?

2013-11-02 Thread Charles Hixson
On 11/02/2013 04:49 PM, TheFlyingFiddle wrote: What are you going to be using the collection for? It's basically a lookup table used for translating external codes (essentially arbitrary) into id#s used internally. There are LOTS of id#s that don't correspond to ANY external code, and nearly

Re: Associative Array: reasonable limits?

2013-11-02 Thread TheFlyingFiddle
What are you going to be using the collection for?

Re: Using reduce() with tuples created by zip()

2013-11-02 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 20:08:15 UTC, Philippe Sigaud wrote: What I'm trying to explain is that reduce takes two arguments: the growing value and the current front. In your case, the current front is indeed a 2-tuple, but that's an unrelated issue. You're trying to get: reduce!( (firstE

Associative Array: reasonable limits?

2013-11-02 Thread Charles Hixson
I'm contemplating an associative array that will eventually grow to be an estimated 64KB in size, assuming it's about half full. It would then be holding around 90,000 entries. Is this reasonable, or should I go with a sorted array, and do binary searches? I estimate that binary searches wou

Re: Trait keyword.

2013-11-02 Thread TheFlyingFiddle
On Saturday, 2 November 2013 at 23:01:51 UTC, H. S. Teoh wrote: On Sat, Nov 02, 2013 at 09:45:26PM +0100, TheFlyingFiddle wrote: I'm basically wondering why the __traits keyword looks so horrible. Because the intention is that users would not use it directly, but via nicer standard library w

Re: Trait keyword.

2013-11-02 Thread H. S. Teoh
On Sat, Nov 02, 2013 at 09:45:26PM +0100, TheFlyingFiddle wrote: > I'm basically wondering why the __traits keyword looks so horrible. Because the intention is that users would not use it directly, but via nicer standard library wrappers (e.g. std.traits in Phobos). T -- I don't trust computer

Figuring out the returntype opDipatch

2013-11-02 Thread TheFlyingFiddle
I'm currently working on a IReflectionable interface Currently the usage is as follows class Foo : IReflectionable { mixin ReflectionImpl; void bar(int a) { /* do something */ } int baz(string a) { return a.length; } } unittest { IReflectionable foo = new Foo(); alias void delega

Re: Trait keyword.

2013-11-02 Thread Adam D. Ruppe
On Saturday, 2 November 2013 at 22:01:11 UTC, Namespace wrote: That looks beautiful to you? In my ideal world, object.d would alias the __ versions back to the regular ones. (Really, it is int, long, etc. that I'd do like this, just like string. for, if, etc. are fine the way they are.) The

Re: Trait keyword.

2013-11-02 Thread Adam D. Ruppe
On Saturday, 2 November 2013 at 22:02:51 UTC, Maxim Fomin wrote: Statement that in D __identifiers are reserved is dubious as nothing stops users from defining them Yeah, but still, you aren't supposed to do it so you can't really complain when it breaks.

Re: Trait keyword.

2013-11-02 Thread Namespace
On Saturday, 2 November 2013 at 21:28:46 UTC, Adam D. Ruppe wrote: On Saturday, 2 November 2013 at 20:45:28 UTC, TheFlyingFiddle wrote: I'm basically wondering why the __traits keyword looks so horrible. I think it looks beautiful and wished all the keywords used the leading underscores. Th

Re: Trait keyword.

2013-11-02 Thread Maxim Fomin
On Saturday, 2 November 2013 at 21:28:46 UTC, Adam D. Ruppe wrote: On Saturday, 2 November 2013 at 20:45:28 UTC, TheFlyingFiddle wrote: I'm basically wondering why the __traits keyword looks so horrible. I think it looks beautiful and wished all the keywords used the leading underscores. Th

Re: Trait keyword.

2013-11-02 Thread TheFlyingFiddle
Thanks for the comprehensive answer.

Re: Trait keyword.

2013-11-02 Thread Adam D. Ruppe
On Saturday, 2 November 2013 at 20:45:28 UTC, TheFlyingFiddle wrote: I'm basically wondering why the __traits keyword looks so horrible. I think it looks beautiful and wished all the keywords used the leading underscores. The reason is that the __keywords are reserved, so they don't conflic

pitfalls of enum

2013-11-02 Thread JR
(TL;DR: when to avoid enum?) From the dlang.org page on enums; Enum declarations are used to define a group of constants. They come in these forms: Named enums, which have an EnumTag. Anonymous enums, which do not have an EnumTag. Manifest constants. Quoth Dmitry Olshansky in my thread on ct

Trait keyword.

2013-11-02 Thread TheFlyingFiddle
I'm basically wondering why the __traits keyword looks so horrible.

Re: Shipping the DMD compiler with code

2013-11-02 Thread Jacob Carlborg
On 2013-11-01 16:47, Colin Grogan wrote: I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl, and the customising came from adding functions to a file and the main script would call those funct

Re: [OT] Generating ddili.org with ddoc

2013-11-02 Thread Ali Çehreli
I will respond later with more information. Here is just the quick ones. :) On 11/02/2013 01:34 AM, Philippe Sigaud wrote: > Where can I get a view of the internal .ddoc file you used for the macro > definitions? They are the ones that end with .ddoc here: https://code.google.com/p/ddili/sou

Re: [OT] Generating ddili.org with ddoc (was: Re: How to iterate using foreach on a class?)

2013-11-02 Thread Philippe Sigaud
On Sat, Nov 2, 2013 at 12:08 AM, Ali Çehreli wrote: > On 11/01/2013 03:51 PM, Philippe Sigaud wrote: > > > What did you use to generate your website, btw? > > It is a completely static web site (except the Google translate widget) > that is produced by ddoc and a couple of Makefiles. This is s