Thread overview | |||||
---|---|---|---|---|---|
|
October 25, 2014 Does it make sense to add attribute to operator overload functions ? | ||||
---|---|---|---|---|
| ||||
Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a custom type. e.g: ----------- struct myType { @safe nothrow opIndexAssign(t1 paramValue,t2 paramIndex){} } ----------- are the attributes necessary ? Are opXXX functions handled just like any other functs ? (traversal compat. of the attribs) |
October 25, 2014 Re: Does it make sense to add attribute to operator overload functions ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jkpl | On Saturday, 25 October 2014 at 17:14:51 UTC, Jkpl wrote:
> Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a custom type.
>
> e.g:
> -----------
> struct myType
> {
> @safe nothrow opIndexAssign(t1 paramValue,t2 paramIndex){}
> }
> -----------
>
> are the attributes necessary ? Are opXXX functions handled just like any other functs ? (traversal compat. of the attribs)
In every aspect they are ordinary functions, except they each have an additional unique way of being called (the relevant operator syntax).
In short, yes.
|
October 25, 2014 Re: Does it make sense to add attribute to operator overload functions ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Saturday, 25 October 2014 at 18:38:12 UTC, John Colvin wrote:
> On Saturday, 25 October 2014 at 17:14:51 UTC, Jkpl wrote:
>> Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a custom type.
>>
>> e.g:
>> -----------
>> struct myType
>> {
>> @safe nothrow opIndexAssign(t1 paramValue,t2 paramIndex){}
>> }
>> -----------
>>
>> are the attributes necessary ? Are opXXX functions handled just like any other functs ? (traversal compat. of the attribs)
>
> In every aspect they are ordinary functions, except they each have an additional unique way of being called (the relevant operator syntax).
>
> In short, yes.
Thx, A bit less confused by them now.
|
Copyright © 1999-2021 by the D Language Foundation