C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS

Hi, in C# you can do some thing like this.

public interface IDataErrorInfo
{
// INDEXER  
string this[string columnName] { get; }
  }
}

how to translate this into D2 ?
thanks in advance, bjoern


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Steven Schveighoffer

On Tue, 29 Jun 2010 09:21:34 -0400, BLS windev...@hotmail.de wrote:


Hi, in C# you can do some thing like this.

public interface IDataErrorInfo
{
 // INDEXER 
 string this[string columnName] { get; }
   }
}

how to translate this into D2 ?
thanks in advance, bjoern


string opIndex(string columnName);


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS

On 29/06/2010 15:27, Steven Schveighoffer wrote:

string opIndex(string columnName);


yeah this is what I did, too..
However defined as ;

interface I1 {
  string opIndex(string columnName);
}

is a no go. So can we say operator overloading within interfaces is not 
allowed in D2 ?


thanks again Steve.. try to learn the interface/property stuff.


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Simen kjaeraas

BLS windev...@hotmail.de wrote:


On 29/06/2010 15:27, Steven Schveighoffer wrote:

string opIndex(string columnName);


yeah this is what I did, too..
However defined as ;

interface I1 {
   string opIndex(string columnName);
}

is a no go.


Hm. That should have worked.

So can we say operator overloading within interfaces is not allowed in  
D2 ?


The new operator overloading scheme has problems with
interfaces. A damned shame if you ask me.

That said, opIndex does not use templates, and should thus
work no problem.


--
Simen


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Trass3r

interface I1 {
   string opIndex(string columnName);
}

is a no go. So can we say operator overloading within interfaces is not  
allowed in D2 ?


It should work.
Only opBinary etc doesn't work yet cause there are problems with template  
functions in interfaces.


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS

On 29/06/2010 15:35, BLS wrote:

On 29/06/2010 15:27, Steven Schveighoffer wrote:

string opIndex(string columnName);


yeah this is what I did, too..
However defined as ;

interface I1 {
string opIndex(string columnName);
}

is a no go. So can we say operator overloading within interfaces is not
allowed in D2 ?

thanks again Steve.. try to learn the interface/property stuff.


Jeez, my mistake.. forget to create the implementation. sorry!


Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Steven Schveighoffer

On Tue, 29 Jun 2010 09:55:50 -0400, BLS windev...@hotmail.de wrote:


On 29/06/2010 15:35, BLS wrote:

On 29/06/2010 15:27, Steven Schveighoffer wrote:

string opIndex(string columnName);


yeah this is what I did, too..
However defined as ;

interface I1 {
string opIndex(string columnName);
}

is a no go. So can we say operator overloading within interfaces is not
allowed in D2 ?

thanks again Steve.. try to learn the interface/property stuff.


Jeez, my mistake.. forget to create the implementation. sorry!


LOL!   :)

As others have said, templates do not yet work in interfaces, and there is  
another subtle problem: templates in interfaces are not virtual so they  
cannot enjoy covariance.  This is a problem for dcollections which uses  
operators in interfaces.


The only solution right now is to reimplement the template in the derived  
classes.


Not a fun situation...

-Steve