Re: std.container update - now Array is in

2010-05-28 Thread Pillsy
== Quote from Andrei Alexandrescu
(seewebsiteforem...@erdani.org)'s article:

 I defined Array as a straightforward implementation of the
 homonym abstraction. There are a few imperfect corners, but
 by and large I'm starting to believe it's becoming possible
 to write certain cross-container codes.

I think it might be a good idea is to make it so that, for struct
types, when they're removed from the containers, their destructors
are run[1]. That way containers would be able to work with some
kinds of smart pointer abstractions once the compiler is up to
supporting them, which would make both the containers and
the smart pointers a good deal more useful.

Cheers,
Pillsy

[1] I asked some questions about the feasibility of this in d.learn.


Re: std.container update - now Array is in

2010-05-28 Thread Steven Schveighoffer
On Thu, 27 May 2010 21:08:29 -0400, Andrei Alexandrescu  
seewebsiteforem...@erdani.org wrote:




http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym  
abstraction. There are a few imperfect corners, but by and large I'm  
starting to believe it's becoming possible to write certain  
cross-container codes.



I just noticed, there is no doc for ElementType, only ValueType and  
KeyType.


-Steve


Re: std.container update - now Array is in

2010-05-28 Thread Steven Schveighoffer
On Fri, 28 May 2010 15:51:53 -0400, Steven Schveighoffer  
schvei...@yahoo.com wrote:


On Thu, 27 May 2010 21:08:29 -0400, Andrei Alexandrescu  
seewebsiteforem...@erdani.org wrote:




http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym  
abstraction. There are a few imperfect corners, but by and large I'm  
starting to believe it's becoming possible to write certain  
cross-container codes.



I just noticed, there is no doc for ElementType, only ValueType and  
KeyType.



Also, ElementType is also a template in std.range, can we change one of  
these?  I would use the following condition to accept a range:



struct container(T)
{

   void add(R)(R r) if (isInputRange!R   
isImplicitlyConvertible(ElementType!R, T)

}

But I think if container(T) defines ElementType, the compiler will be  
confused...


-Steve


Re: std.container update - now Array is in

2010-05-28 Thread Andrei Alexandrescu

On 05/28/2010 02:51 PM, Steven Schveighoffer wrote:

On Thu, 27 May 2010 21:08:29 -0400, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:



http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym
abstraction. There are a few imperfect corners, but by and large I'm
starting to believe it's becoming possible to write certain
cross-container codes.



I just noticed, there is no doc for ElementType, only ValueType and
KeyType.

-Steve


I figured out that ElementType is actually unneeded - introspection can 
extract it for you, see std.range.ElementType.


Andrei


Re: std.container update - now Array is in

2010-05-28 Thread Steven Schveighoffer
On Fri, 28 May 2010 16:03:10 -0400, Andrei Alexandrescu  
seewebsiteforem...@erdani.org wrote:



On 05/28/2010 02:51 PM, Steven Schveighoffer wrote:

On Thu, 27 May 2010 21:08:29 -0400, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:



http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym
abstraction. There are a few imperfect corners, but by and large I'm
starting to believe it's becoming possible to write certain
cross-container codes.



I just noticed, there is no doc for ElementType, only ValueType and
KeyType.

-Steve


I figured out that ElementType is actually unneeded - introspection can  
extract it for you, see std.range.ElementType.


Well, the docs still use ElementType everywhere.  I don't really know how  
it would be introspected, what common function are all containers expected  
to implement (analogous to front() in a range)?


The only thing I would suggest is that having ElementType or something  
equivalent, would help with documentation, since ddoc would be immune to  
said introspection.


-Steve


std.container update - now Array is in

2010-05-27 Thread Andrei Alexandrescu


http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym 
abstraction. There are a few imperfect corners, but by and large I'm 
starting to believe it's becoming possible to write certain 
cross-container codes.



Andrei


Re: std.container update - now Array is in

2010-05-27 Thread Michel Fortin
On 2010-05-27 21:08:29 -0400, Andrei Alexandrescu 
seewebsiteforem...@erdani.org said:




http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym 
abstraction. There are a few imperfect corners, but by and large I'm 
starting to believe it's becoming possible to write certain 
cross-container codes.


I don't get that:

@property void reserve(size_t e)

Why is reserve a property? You want it called like that?

array.reserve = 10;

I'm sure it's just an oversight.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/



Re: std.container update - now Array is in

2010-05-27 Thread Andrei Alexandrescu

On 05/27/2010 09:27 PM, Michel Fortin wrote:

On 2010-05-27 21:08:29 -0400, Andrei Alexandrescu
seewebsiteforem...@erdani.org said:



http://erdani.com/d/phobos/std_container.html
http://erdani.com/d/phobos/container.d

I defined Array as a straightforward implementation of the homonym
abstraction. There are a few imperfect corners, but by and large I'm
starting to believe it's becoming possible to write certain
cross-container codes.


I don't get that:

@property void reserve(size_t e)

Why is reserve a property? You want it called like that?

array.reserve = 10;

I'm sure it's just an oversight.


Sorry, fixed now.

Andrei