Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
June 29, 2010 C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
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 |
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | 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);
|
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | 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.
|
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | 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 |
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | > 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.
|
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to 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!
|
June 29, 2010 Re: C# Indexers. how to implement them in D.. also property related. | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | 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
|
Copyright © 1999-2021 by the D Language Foundation