dmd output executable vs valgrind --tool=massif

2013-03-09 Thread Druzhinin Alexandr
Massif (and valgrind in general) is a nice tool and using it I tried to investigate where memory leaks. I found that more than 50% of heap consumed by unknown code. How can I get what those symbols is? May be there is some option to hint valgrind where to find symbols or may be I should rebuild

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
On Saturday, 9 March 2013 at 23:40:25 UTC, Zhenya wrote: Although of course I would want to know what's wrong with constrait,because it protect doArray against incorrect using. I don't worry about effiency very much,I just wanted to right n-dimensional tree of intervals.And for doing it I needed

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
Although of course I would want to know what's wrong with constrait,because it protect doArray against incorrect using. I don't worry about effiency very much,I just wanted to right n-dimensional tree of intervals.And for doing it I needed n-dimensional array with opIndex like it.

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
On Saturday, 9 March 2013 at 23:05:56 UTC, Ivan Kazmenko wrote: this code fails with message:NDimensionalArray.doIndex(Array) if (is(Array _ : NDimensionalArrayType!(T,s),const(int[]) s)) cannot deduce template function from argument types !()(int[2u][2u],const(int[])) Tell me please,am I wro

Re: how to get top N distinct elements from range?

2013-03-09 Thread Timon Gehr
On 03/09/2013 10:35 AM, Andrea Fontana wrote: ... this works. Is this: bool[typeof(_fun((ElementType!Range).init))] mySet; the right way? It's ok, but the redundant parentheses around the element type are confusing.

Re: question with compile-time reflection

2013-03-09 Thread Ivan Kazmenko
this code fails with message:NDimensionalArray.doIndex(Array) if (is(Array _ : NDimensionalArrayType!(T,s),const(int[]) s)) cannot deduce template function from argument types !()(int[2u][2u],const(int[])) Tell me please,am I wrong? And if yes,what should I change to make it work? I'm no D e

Re: question with compile-time reflection

2013-03-09 Thread Rob T
template NDimensionalArrayType(T,alias size) I think your use of "alias size" is incorrect. See http://dlang.org/declaration.html --rt

Re: how to get top N distinct elements from range?

2013-03-09 Thread bearophile
Andrei Alexandrescu: Yah, There are 3 problems: - In a successive post I have also added a template constraint, so Range is an InputRange. - firstDistinct() packs two behaviours that are better kept separated, it's like a takeDistinct. It's better to remove the final take, and return all di

Re: how to get top N distinct elements from range?

2013-03-09 Thread Andrei Alexandrescu
On 3/8/13 1:34 PM, Chris Cain wrote: On Friday, 8 March 2013 at 18:17:22 UTC, bearophile wrote: auto firstDistinct(Range)(Range r, in size_t n) { bool[ForeachType!Range] mySet; return r.filter!((k) { if (k in mySet) return false; mySet[k] = true; return true; }).take(n); } I have to say, tha

Re: how to get top N distinct elements from range?

2013-03-09 Thread bearophile
Andrea Fontana: Maybe two versions (filter and cachedFilter) or a bool template param? In the meantime I have filed the problem, I hope Andrei will take a look: http://d.puremagic.com/issues/show_bug.cgi?id=9674 Bye, bearophile

Re: how to get top N distinct elements from range?

2013-03-09 Thread bearophile
Andrea Fontana: Is this: bool[typeof(_fun((ElementType!Range).init))] mySet; the right way? I don't know if that's the best way, but I think it's OK. (I think it should even go in the D wiki, so if it's not the best to do it, someone will improve it.) Bye, bearophile

question with compile-time reflection

2013-03-09 Thread Zhenya
Hi! this code fails with message:NDimensionalArray.doIndex(Array) if (is(Array _ : NDimensionalArrayType!(T,s),const(int[]) s)) cannot deduce template function from argument types !()(int[2u][2u],const(int[])) Tell me please,am I wrong? And if yes,what should I change to make it work? templ

Re: Appender cannot add struct with immutable members

2013-03-09 Thread monarch_dodra
On Friday, 8 March 2013 at 22:59:23 UTC, Namespace wrote: Wow, very large. I'm going to read this tomorrow in a rested state in more detail. But it arouses my interest to write something yourself from scratch. But a quick question: Why is the internal array in the separate struct 'Data' encapsu

Re: how to get top N distinct elements from range?

2013-03-09 Thread Andrea Fontana
On Saturday, 9 March 2013 at 09:32:43 UTC, Andrea Fontana wrote: On Saturday, 9 March 2013 at 09:13:26 UTC, Andrea Fontana wrote: On Saturday, 9 March 2013 at 01:36:53 UTC, bearophile wrote: Is it a good idea to replace std.algorithm.filter with something like that filter2 (plus some missing

Re: how to get top N distinct elements from range?

2013-03-09 Thread Andrea Fontana
On Saturday, 9 March 2013 at 09:13:26 UTC, Andrea Fontana wrote: On Saturday, 9 March 2013 at 01:36:53 UTC, bearophile wrote: Is it a good idea to replace std.algorithm.filter with something like that filter2 (plus some missing methods)? Bye, bearophile Maybe two versions (filter and cache

Re: how to get top N distinct elements from range?

2013-03-09 Thread Andrea Fontana
On Saturday, 9 March 2013 at 01:36:53 UTC, bearophile wrote: Is it a good idea to replace std.algorithm.filter with something like that filter2 (plus some missing methods)? Bye, bearophile Maybe two versions (filter and cachedFilter) or a bool template param? I was thinking about @pure f