I've thought a lot about how I imagine my 'ideal' language for general purposes. I even started to write a compiler for it, but stopped because I ran into several uncertainties about how it should work. I thought one of them would make a good question to ask here.
func = (arg1, arg2) => statement1 statement2
But another part of the plan was to implement polymorphism by allowing multiple functions of the same name as long as they have different type signatures. Structs don't have methods; you just declare a function that take a function take them as its first argument. In paricular,
object.method(arg) is actually sugar for
method(object, arg). (That interpretation of the dot syntax is one idea I've come up with that's not borrowed from another language I know)
But can these be reconciled? How do you declare an implementation of the function for a different type if that would require assigning to the variable, which would overwrite its previous value (I wouldn't entertain the thought of having the
= mean something different for function values on the right)?
I would declare it's impossible, but I also thought default arguments couldn't be reconciled with automatic currying and OCaml proved me wrong.