Re: dcollections 1.0 and 2.0a beta released

2010-05-28 Thread Jacob Carlborg
On 2010-05-27 12:32, Steven Schveighoffer wrote: On Wed, 26 May 2010 10:06:32 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I have built a C++ library that abstracted features of the OS. My goal was to make it possible

Re: dcollections 1.0 and 2.0a beta released

2010-05-28 Thread Bruno Medeiros
On 27/05/2010 11:32, Steven Schveighoffer wrote: On Wed, 26 May 2010 10:06:32 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I have built a C++ library that abstracted features of the OS. My goal was to make it possible

Re: dcollections 1.0 and 2.0a beta released

2010-05-28 Thread Steven Schveighoffer
On Fri, 28 May 2010 06:24:26 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 27/05/2010 11:32, Steven Schveighoffer wrote: On Wed, 26 May 2010 10:06:32 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I

Re: dcollections 1.0 and 2.0a beta released

2010-05-28 Thread Steven Schveighoffer
On Fri, 28 May 2010 06:10:49 -0400, Jacob Carlborg d...@me.com wrote: On 2010-05-27 12:32, Steven Schveighoffer wrote: On Wed, 26 May 2010 10:06:32 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I have built a C++

Re: dcollections 1.0 and 2.0a beta released

2010-05-27 Thread Steven Schveighoffer
On Wed, 26 May 2010 10:06:32 -0400, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I have built a C++ library that abstracted features of the OS. My goal was to make it possible to dynamically load a module that abstracted

Re: dcollections 1.0 and 2.0a beta released

2010-05-26 Thread Bruno Medeiros
On 24/05/2010 16:45, Andrei Alexandrescu wrote: In the past I have built a C++ library that abstracted features of the OS. My goal was to make it possible to dynamically load a module that abstracted things like setting the IP address of a network interface. My modules used std::string instead

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Jacob Carlborg
On 2010-05-23 23.36, Andrei Alexandrescu wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are nonessential. Here they are: 1. Using a class

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Sat, 22 May 2010 16:58:12 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/19/2010 03:07 PM, Steven Schveighoffer wrote: Ellery Newcomer Wrote: Are the collections supposed to not have isEmpty members? No. Use length == 0. O(1) length is always supported for all

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Thu, 20 May 2010 12:46:59 -0400, Robert Jacques sandf...@jhu.edu wrote: On Thu, 20 May 2010 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Robert Jacques Wrote: On Wed, 19 May 2010 21:42:35 -0400, Steven Schveighoffer Does that make sense? -Steve Yes and No. I

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Fri, 21 May 2010 14:00:42 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/20/2010 05:34 AM, Steven Schveighoffer wrote: I understand these points, but I'm already using interfaces to copy data between containers. I don't have to, I could have used generic code,

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 06:54 AM, Steven Schveighoffer wrote: length is allowed to return NO_LENGTH_SUPPORT if O(1) length isn't possible, Do you agree that's an awkwardness? but all dcollections define length. I was hoping we're on the verge of agreeing to yank all interfaces and let the

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 06:54 AM, Steven Schveighoffer wrote: I am not familiar with tries, Missed that upon the first read. I suggest you look at tries and the following other structures as good examples that it's futile to fit collections into hierarchies. http://en.wikipedia.org/wiki/Trie

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 10:10:51 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 06:54 AM, Steven Schveighoffer wrote: length is allowed to return NO_LENGTH_SUPPORT if O(1) length isn't possible, Do you agree that's an awkwardness? Yes, at that point it's an

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 10:23 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 10:10:51 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 06:54 AM, Steven Schveighoffer wrote: length is allowed to return NO_LENGTH_SUPPORT if O(1) length isn't possible, Do you agree

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 10:39 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 11:21:20 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 06:54 AM, Steven Schveighoffer wrote: I am not familiar with tries, Missed that upon the first read. I suggest you look at tries and

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Steven Schveighoffer
On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Robert Jacques
On Mon, 24 May 2010 08:06:29 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 20 May 2010 12:46:59 -0400, Robert Jacques sandf...@jhu.edu wrote: On Thu, 20 May 2010 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: [snip] I understand these points, but I'm

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 11:45:44 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:23 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 10:10:51 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 06:54 AM, Steven Schveighoffer wrote:

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 10:58 AM, Steven Schveighoffer wrote: On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter.

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 11:51:39 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:39 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 11:21:20 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 06:54 AM, Steven Schveighoffer wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 11:14 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 11:45:44 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:23 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 10:10:51 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 11:45:51 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:01 AM, Steven Schveighoffer wrote: On Fri, 21 May 2010 13:42:14 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/19/2010 08:42 PM, Steven Schveighoffer wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 12:06:18 -0400, Robert Jacques sandf...@jhu.edu wrote: On Mon, 24 May 2010 08:06:29 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Thu, 20 May 2010 12:46:59 -0400, Robert Jacques sandf...@jhu.edu wrote: On Thu, 20 May 2010 06:34:42 -0400, Steven

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 12:18:02 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:58 AM, Steven Schveighoffer wrote: On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 13:11:27 -0400, Simen kjaeraas simen.kja...@gmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote: And if 3rd party X _needs_ to use interfaces, and 3rd party Y _needs_ to use interfaces, and your code depends on X and Y, and interfaces aren't defined by

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 12:11 PM, bearophile wrote: Steven Schveighoffer: Is it unreasonable to expect to be able to iterate the keys in a trie? (I don't really know, I've never worked with them) On tries you can iterate on all keys or on a sorted range of the keys. There's one more way of iteration

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 13:36:01 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 12:11 PM, bearophile wrote: Steven Schveighoffer: Is it unreasonable to expect to be able to iterate the keys in a trie? (I don't really know, I've never worked with them) On tries

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Thu, 20 May 2010 02:11:58 -0400, Bernard Helyer b.hel...@gmail.com wrote: On 20/05/10 13:39, Bernard Helyer wrote: Oooohhh goody goody goody! n_n I'm in the process of making a little toy project ATM. I'll shall integrate dcollections 2.0a into ASAP. ArrayList doesn't compile with

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 12:27:10 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 11:14 AM, Steven Schveighoffer wrote: On Mon, 24 May 2010 11:45:44 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:23 AM, Steven Schveighoffer wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Pelle
On 05/24/2010 06:27 PM, Andrei Alexandrescu wrote: struct List { int v; List * next; } While I do agree with that design for a list, that is no reference type. I thought we wanted reference types.

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread bearophile
Steven Schveighoffer: Look at D's arrays. Is appending with D's arrays the fastest it possibly could be? Hell no, but it's good enough for most situations, and safe. Append in D dynamic arrays is awful, it's slow and requires complex code (and currently there are not explanations about how

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread bearophile
And the appending is hard to use too, see the ridiculously complex to use messy capacity, reserve and and assumeSafeAppend. So overall it's a good example of what I will never want to copy. Bye, bearophile

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 15:32:01 -0400, bearophile bearophileh...@lycos.com wrote: And the appending is hard to use too, see the ridiculously complex to use messy capacity, reserve and and assumeSafeAppend. So overall it's a good example of what I will never want to copy. That part is

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 15:29:23 -0400, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: Look at D's arrays. Is appending with D's arrays the fastest it possibly could be? Hell no, but it's good enough for most situations, and safe. Append in D dynamic arrays is awful, it's

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 01:12 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 13:36:01 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 12:11 PM, bearophile wrote: Steven Schveighoffer: Is it unreasonable to expect to be able to iterate the keys in a trie? (I don't

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread bearophile
Steven Schveighoffer: complex code? a ~= b; Seems pretty not complex. I meant on the implementation side. Arrays are used all the time, and they are basic blocks to be used everywhere so a programmer probably must understand how they work inside. That part is still pretty new. What do

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 01:49 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 12:27:10 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: A pointer to the end element would be required for both appending and back(). This further erodes my confidence. Size needs to be maintained _and_ a

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 02:01 PM, Pelle wrote: On 05/24/2010 06:27 PM, Andrei Alexandrescu wrote: struct List { int v; List * next; } While I do agree with that design for a list, that is no reference type. List* is. My point was that the pressure for a really simple hand-rolled SLL is huge. A

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 02:29 PM, bearophile wrote: Steven Schveighoffer: Look at D's arrays. Is appending with D's arrays the fastest it possibly could be? Hell no, but it's good enough for most situations, and safe. Append in D dynamic arrays is awful, it's slow and requires complex code (and

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 15:58:46 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 01:12 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 13:36:01 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 12:11 PM, bearophile wrote: Steven

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 03:18 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 15:58:46 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 01:12 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 13:36:01 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread bearophile
Andrei Alexandrescu: When was the last time you measured? I thought the speed has largely improved since Steve integrated his work. I have timed it after that integration. I have seen a performance improvement, but it's small. I can perform some syntactic benchmarks. Later, bearophile

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 16:07:22 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 01:49 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 12:27:10 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: A pointer to the end element would be required for

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 16:27:46 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: Sorry. Yes, by-key iteration should be possible. OK, so we should be able to iterate keys. And the keys are not stored in the trie structure itself. So how does one iterate the keys of the

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 04:08 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 16:27:46 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: Sorry. Yes, by-key iteration should be possible. OK, so we should be able to iterate keys. And the keys are not stored in the trie structure

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 04:38 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 17:35:11 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 04:08 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 16:27:46 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 17:47:18 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 04:38 PM, Steven Schveighoffer wrote: On Mon, 24 May 2010 17:35:11 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 04:08 PM, Steven Schveighoffer wrote:

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Simen kjaeraas
Steven Schveighoffer schvei...@yahoo.com wrote: On the flip side, if containers did not implement interfaces, having to do this: class WrappedSet!(alias Impl, V) : Set!V { private Impl!V impl; int functionToSatisfySet() { return impl.functionToSatisfySet(); } ... } seems to me

Re: dcollections 1.0 and 2.0a beta released

2010-05-24 Thread Justin Spahr-Summers
On Mon, 24 May 2010 11:01:06 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: It's done all the time in Java and .NET. For example, A GUI listbox widget exposes its elements as an array of elements, which implement the List interface. You don't ever see the implementation or need

Re: dcollections 1.0 and 2.0a beta released

2010-05-23 Thread Michel Fortin
On 2010-05-22 16:01:37 -0400, Walter Bright newshou...@digitalmars.com said: Michel Fortin wrote: What's the point of having extra indirection here? Good question. I think the answer is: 1. When do you ever want to copy a collection? I almost never do, because copying one is an inherently

struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-23 Thread Andrei Alexandrescu
I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are nonessential. Here they are: 1. Using a class makes implementing members easier because there's

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-23 Thread Michel Fortin
On 2010-05-23 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org said: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are

Re: dcollections 1.0 and 2.0a beta released

2010-05-23 Thread BLS
Fantastic work Steve, Pretty good design IMHO, not sure why .. but somehow the collection battle reminds me to Steve Vai vs Ry Cooder vbg Bjoern

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread bearophile
BCS: Maybe the style rule should be: dynamic arrays and AA's should be passed as const or ref. Something like that must be enforced by the compiler, or the design of arrays/AAs must be changed. Bye, bearophile

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Pelle
On 05/22/2010 12:20 PM, bearophile wrote: BCS: Maybe the style rule should be: dynamic arrays and AA's should be passed as const or ref. Something like that must be enforced by the compiler, or the design of arrays/AAs must be changed. Bye, bearophile It's not a very good rule anyway:

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread bearophile
Pelle: It's not a very good rule anyway: void inc_all(int[] xs) { foreach (ref x; xs) { x += 1; } } Wouldn't gain anything from ref, and wouldn't work with const. You are wrong, it works correctly with ref: import std.stdio: writeln; void inc_all(ref int[] array)

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread bearophile
Pelle: Yes, it works, but it doesn't gain anything from it, which is what I said. :) Then what you have said was useless. Bye, bearophile

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Michel Fortin
On 2010-05-21 22:55:16 -0400, Walter Bright newshou...@digitalmars.com said: Walter Bright wrote: If we can get anywhere close to that level of success with ranges and containers, we should all be well pleased. Mike Taylor has a phrase for that I think is well-coined: impedance matching,

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Michel Fortin
On 2010-05-22 07:56:31 -0400, Michel Fortin michel.for...@michelf.com said: @explicitdup struct Array { } void testVal(Array array); void testRef(ref Array array); unittest { Array array; testVal(array); // error, cannot

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Simen kjaeraas
BCS n...@anon.com wrote: Cool. Now how do I write code so that it will always iterate the collection with the bigger O() lookup time (O(n) before O(log2(n)) before O(log16(n)) before O(1))? :D Add a function. auto foo( R1, R2 )( R1 r1, R2 r2 ) if ( R1.complexity( 10_000 )

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Pelle
On 05/22/2010 01:28 PM, bearophile wrote: Pelle: Yes, it works, but it doesn't gain anything from it, which is what I said. :) Then what you have said was useless. Bye, bearophile How so? Passing by reference is slower, and sometimes completely meaningless. Therefore, having a rule that

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Andrei Alexandrescu
On 05/19/2010 03:07 PM, Steven Schveighoffer wrote: Ellery Newcomer Wrote: Are the collections supposed to not have isEmpty members? No. Use length == 0. O(1) length is always supported for all collections. One thing before I forget: I think any good collection abstraction must be

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread bearophile
Andrei Alexandrescu: Keeping the length cached in a singly-linked list is a costly mistake. It works against splicing (an important list primitive) and most of the time you don't need it so why waste time updating it. ... LinkedList(T, bool WithLength=True) { static if(WithLength) { //

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Sean Kelly
Andrei Alexandrescu Wrote: One thing before I forget: I think any good collection abstraction must be concretized back to the classic collection instances. Singly-linked lists definitely can't be left off the list! It would be an epic failure. Imagine the papers! New York Times: D has

Re: dcollections 1.0 and 2.0a beta released

2010-05-22 Thread Andrei Alexandrescu
On 05/22/2010 09:07 PM, Sean Kelly wrote: Andrei Alexandrescu Wrote: One thing before I forget: I think any good collection abstraction must be concretized back to the classic collection instances. Singly-linked lists definitely can't be left off the list! It would be an epic failure. Imagine

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Steven Schveighoffer
superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Andrei Alexandrescu Wrote: To get back to one of my earlier points, the fact that the container interfaces are unable to express iteration is a corollary of the design's problem and an climactic

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread superdan
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Andrei Alexandrescu Wrote: To get back to one of my earlier points, the fact that the container interfaces are unable to express

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Steven Schveighoffer
superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Is there some other reason to use structs besides copy construction? -Steve memory management n shit. with a struct u can use refcounting n malloc n realloc n shit. still stays a reference type. nothing

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread superdan
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Is there some other reason to use structs besides copy construction? -Steve memory management n shit. with a struct u can use

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Steven Schveighoffer
superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Is there some other reason to use structs besides copy construction? -Steve memory management n shit. with a

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Ellery Newcomer
On 05/21/2010 09:14 AM, Steven Schveighoffer wrote: Second, since reference types are the right thing to do, classes are much easier to deal with. I know AA's are reference types that are structs, but the code needed to perform this feat is not trivial. The AA has only one member, a

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Bill Baxter
On Fri, May 21, 2010 at 9:43 AM, Steven Schveighoffer schvei...@yahoo.com wrote: superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Is there some other reason to use

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/19/2010 07:21 PM, bearophile wrote: Andrei Alexandrescu: Destroy me :o). You ideas are surely interesting, but I don't think there's a simple way to change his code according to your ideas. People can use the dcollections in the following weeks and months, and when you have implemented

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Ellery Newcomer
On 05/21/2010 11:55 AM, Ellery Newcomer wrote: On 05/21/2010 09:14 AM, Steven Schveighoffer wrote: Second, since reference types are the right thing to do, classes are much easier to deal with. I know AA's are reference types that are structs, but the code needed to perform this feat is not

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/19/2010 07:57 PM, Bill Baxter wrote: On Wed, May 19, 2010 at 4:01 PM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: My vision, in very brief, is to foster a federation of independent containers abiding to identical names for similar functionality. Then a few concept checks (a

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/19/2010 08:42 PM, Steven Schveighoffer wrote: Andrei Alexandrescu Wrote: To get back to one of my earlier points, the fact that the container interfaces are unable to express iteration is a corollary of the design's problem and an climactic disharmony. My vision, in very brief, is to

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread superdan
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article superdan Wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article Is there some other reason to use structs besides

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/19/2010 09:59 PM, Robert Jacques wrote: On Wed, 19 May 2010 21:42:35 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Andrei Alexandrescu Wrote: To get back to one of my earlier points, the fact that the container interfaces are unable to express iteration is a corollary of the

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/20/2010 08:22 AM, Steven Schveighoffer wrote: Michel Fortin Wrote: On 2010-05-20 06:34:42 -0400, Steven Schveighofferschvei...@yahoo.com said: I understand these points, but I'm already using interfaces to copy data between containers. I don't have to, I could have used generic code,

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/20/2010 06:17 AM, Michel Fortin wrote: On 2010-05-20 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com said: I understand these points, but I'm already using interfaces to copy data between containers. I don't have to, I could have used generic code, but this way, only one

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/20/2010 09:14 AM, Pelle wrote: On 05/20/2010 03:22 PM, Steven Schveighoffer wrote: One thing I just thought of -- in dcollections, similar types can be compared to one another. For example, you can check to see if a HashSet is equal to a TreeSet. But that would not be possible without

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/20/2010 09:41 AM, Michel Fortin wrote: On 2010-05-20 08:30:59 -0400, bearophile bearophileh...@lycos.com said: Michel Fortin: Surely going through all those virtual calls slows things down a lot. Right. But the purpose of a good compiler is to kill those, devirtualizing. LLVM devs

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Andrei Alexandrescu
On 05/20/2010 02:47 PM, bearophile wrote: Michel Fortin: Devirtualization is only possible in certain cases: when the function knows exactly which type it'll get. You are wrong, in most cases there are ways to de-virtualize, even when the runtime type isn't exactly known, but sometimes to do

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Bill Baxter
On Fri, May 21, 2010 at 10:50 AM, superdan su...@dan.org wrote: void foo(int[int] x) {    x[5] = 5; } void main() {    int[int] x;    foo(x);    assert(x[5] == 5); // fails } -Steve wrote a long post but it got lost. shit. bottom line dats a bug in dmd or phobos. Unfortunately it

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Walter Bright
Andrei Alexandrescu wrote: I wrote a solution to the problem in native D. It goes like this: alias Container!(int, addable | purgeable) Messerschmidt; void messWith(Messerschmidt i) { ... use i's capabilities to add and purge ... } I agree with Michael Fortin that the | is questionable.

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Walter Bright
Andrei Alexandrescu wrote: On 05/19/2010 09:59 PM, Robert Jacques wrote: Yes and No. I understand where your coming from, but I think it's a bad idea. First, I think it needlessly expands the radius of comprehension needed to understand and use the library. (See Tangled up in tools

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread Walter Bright
Walter Bright wrote: If we can get anywhere close to that level of success with ranges and containers, we should all be well pleased. Mike Taylor has a phrase for that I think is well-coined: impedance matching, defined as the work necessary to get one library module to work with another

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread BCS
Hello superdan, dun tell me it dun work. i dun explain shit again. it works coz a struct cant be null. but a struct can be a ref if it only haz one pointer inside. methinks the builtin hash iz dat way. void foo(container!shit poo) { if(!poo) poo = new container!shit; // fuck dat shit

Re: dcollections 1.0 and 2.0a beta released

2010-05-21 Thread BCS
Hello Vladimir, On Thu, 20 May 2010 04:42:35 +0300, Steven Schveighoffer schvei...@yahoo.com wrote: interfaces Does that imply that the most important methods are virtual? If so, say good-bye to inlining, and hello to an additional level of dereferencing. From a technical standpoint

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Bernard Helyer
On 20/05/10 13:39, Bernard Helyer wrote: Oooohhh goody goody goody! n_n I'm in the process of making a little toy project ATM. I'll shall integrate dcollections 2.0a into ASAP. ArrayList doesn't compile with warnings as it overrides opEquals, but doesn't mark it as such.

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Bernard Helyer
On 20/05/10 18:11, Bernard Helyer wrote: On 20/05/10 13:39, Bernard Helyer wrote: Oooohhh goody goody goody! n_n I'm in the process of making a little toy project ATM. I'll shall integrate dcollections 2.0a into ASAP. ArrayList doesn't compile with warnings as it overrides opEquals, but

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Bernard Helyer
On 20/05/10 18:16, Bernard Helyer wrote: On 20/05/10 18:11, Bernard Helyer wrote: On 20/05/10 13:39, Bernard Helyer wrote: Oooohhh goody goody goody! n_n I'm in the process of making a little toy project ATM. I'll shall integrate dcollections 2.0a into ASAP. ArrayList doesn't compile with

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Steven Schveighoffer
Robert Jacques Wrote: On Wed, 19 May 2010 21:42:35 -0400, Steven Schveighoffer Does that make sense? -Steve Yes and No. I understand where your coming from, but I think it's a bad idea. First, I think it needlessly expands the radius of comprehension needed to understand and

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread bearophile
Michel Fortin: Surely going through all those virtual calls slows things down a lot. Right. But the purpose of a good compiler is to kill those, devirtualizing. LLVM devs are working on this too. See: http://llvm.org/bugs/show_bug.cgi?id=6054 http://llvm.org/bugs/show_bug.cgi?id=3100

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Steven Schveighoffer
Michel Fortin Wrote: On 2010-05-20 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com said: I understand these points, but I'm already using interfaces to copy data between containers. I don't have to, I could have used generic code, but this way, only one function is

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Pelle
On 05/20/2010 03:22 PM, Steven Schveighoffer wrote: One thing I just thought of -- in dcollections, similar types can be compared to one another. For example, you can check to see if a HashSet is equal to a TreeSet. But that would not be possible without interfaces. -Steve I'm sorry, but

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Michel Fortin
On 2010-05-20 09:22:27 -0400, Steven Schveighoffer schvei...@yahoo.com said: Michel Fortin Wrote: On 2010-05-20 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com said: I understand these points, but I'm already using interfaces to copy data between containers. I don't have to, I

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Michel Fortin
On 2010-05-20 08:30:59 -0400, bearophile bearophileh...@lycos.com said: Michel Fortin: Surely going through all those virtual calls slows things down a lot. Right. But the purpose of a good compiler is to kill those, devirtualizing. LLVM devs are working on this too. See:

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread bearophile
Steven Schveighoffer: You get a much higher speedup when things can be inlined than virtual vs. non-virtual. In current D compilers virtual functions prevent inlining. This can give some performance loss. Bye, bearophile

Re: dcollections 1.0 and 2.0a beta released

2010-05-20 Thread Robert Jacques
On Thu, 20 May 2010 06:34:42 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Robert Jacques Wrote: On Wed, 19 May 2010 21:42:35 -0400, Steven Schveighoffer Does that make sense? -Steve Yes and No. I understand where your coming from, but I think it's a bad idea. First, I think it

  1   2   >