Operator overloading

Xan xancorreu at gmail.com
Sat Apr 21 12:10:11 PDT 2012


Thank you very very much, Dmitry. Now all it's fine!

Xan.

On Friday, 20 April 2012 at 19:51:40 UTC, Dmitry Olshansky wrote:
> On 20.04.2012 23:33, Xan wrote:
>>> Yes, you're wright. So in.
>>>
>>> But what fails?
>>>
>>> I reveice these errors and I have no idea what fails!
>>>
>>
>> Sorry, the errors are:
>>
>> $ gdmd-4.6 algorisme.d
>> algorisme.d:35: Error: 'this' is only defined in non-static 
>> member
>> functions, not __funcliteral1
>
> Easy - _this_ inside of
>  function (T t) { return this.funcio(alg.funcio(t)); }
>
> Is not going to fly because there is no way to "store" _this_ 
> in function, use delegates (this is a context and it has to be 
> "copied" -> use delegates). But then you'd have to change to 
> delegate everywhere.
>
> (and there is toDelegate function in std.functional, that 
> converts function to delegate)
>
>> algorisme.d:35: Error: function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary.__funcliteral1
>> cannot access frame of function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary
>> algorisme.d:35: Error: function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary.__funcliteral1
>> cannot access frame of function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary
>> algorisme.d:35: Error: function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary.__funcliteral1
>> cannot access frame of function
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int).opBinary
>> algorisme.d:35: Error: constructor
>> algorisme.Algorisme!(int,int).Algorisme.this (string nom, uint 
>> versio,
>> int function(int) funcio) is not callable using argument types
>> (string,int,_error_ function(int t) nothrow @system)
>> algorisme.d:35: Error: cannot implicitly convert expression
>> (__funcliteral1) of type _error_ function(int t) nothrow 
>> @system to int
>> function(int)
>> algorisme.d:52: Error: template instance
>> algorisme.Algorisme!(int,int).Algorisme.opBinary!("*",int) 
>> error
>> instantiating
>>
>>
>>
>> I update the gist: https://gist.github.com/2429005




More information about the Digitalmars-d-learn mailing list