digitalmars.D.learn - C# Indexers. how to implement them in D.. also property related.
- BLS <windevguy hotmail.de> Jun 29 2010
- "Steven Schveighoffer" <schveiguy yahoo.com> Jun 29 2010
- BLS <windevguy hotmail.de> Jun 29 2010
- BLS <windevguy hotmail.de> Jun 29 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Jun 29 2010
- Trass3r <un known.com> Jun 29 2010
- "Steven Schveighoffer" <schveiguy yahoo.com> Jun 29 2010
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
Jun 29 2010
On Tue, 29 Jun 2010 09:21:34 -0400, BLS <windevguy 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);
Jun 29 2010
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.
Jun 29 2010
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!
Jun 29 2010
BLS <windevguy 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
Jun 29 2010
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.
Jun 29 2010
On Tue, 29 Jun 2010 09:55:50 -0400, BLS <windevguy 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
Jun 29 2010









BLS <windevguy hotmail.de> 