wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
224 stars 30 forks source link

function overloading #20

Closed Frotty closed 12 years ago

Frotty commented 12 years ago

example:

function print( string msg )

function print( unit u )

etc.

Would be cool

peq commented 12 years ago

This would break the current resolution rules for function references as in "TimerStart(..., function print)". Please also add suggestions on how to change this with respect to overloading.

Frotty commented 12 years ago

"You can't use overloaded functions in callbacks" :D

peq commented 12 years ago

What should the exact rules for overloading be? Maybe you can take http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2 as an inspiration for the specification. Or you see that overloading can add quite some complexity to the language. Of course it will be simpler for Wurst as we have no backwards compatibility issues and no boxing and no type coercions but still we have to think about how overloading works with overriding, subtyping, packages, type inference, generics, etc.

You might also want to read http://www.roseindia.net/javatutorials/overloading_considered_harmful.shtml

So currently I am against adding overloading.

Frotty commented 12 years ago

meh, I (ofc) didn't think about the full scale consequences, it would just be a cool enhancement to have.

peq commented 12 years ago

The point is: I am not sure if it is an enhancement and it surely will complicate the compiler :D

peq commented 12 years ago

Done, but still needs some testing and documentation.