quoted c# clr
the clr specification mandates operator overload methods public , static methods.
i checked ecma-335, couldn't find evidence.
so far know true c# , f#. true cls-compliant language?
it looks it's not really required public, making non-static problematic @ execution time. experimented starting code:
using system; class oddity { public static oddity operator+(oddity x, oddity y) { console.writeline("adding oddities"); return null; } } class test { static void main() { var x = new oddity(); var y = new oddity(); var z = x + y; } }
... , running through ildasm
, changing things, using ilasm
, running result.
- changing accessibility modifier
assembly
(equivalentinternal
): fine changing accessibility modifier
private
: assembled (which surprised me) failed @ execution time:unhandled exception: system.methodaccessexception: attempt method 'test.main()' access method 'oddity.op_addition(oddity, oddity)' failed.
@ test.main()removing
static
part: assembled (again, surprising me) failed @ execution time:unhandled exception: system.missingmethodexception: method not found: 'oddity oddity.op_addition(oddity, oddity)'.
@ test.main()
i suspect these should caught @ assembly time, languages expected produce operators public , static, validator little lax.
Comments
Post a Comment