In Lua there's a short notation for sending the "self" to a function, so a.withdraw(a, 100.0) can be written a:withdraw(100.0). Shouldn't it be possible to do a similar extension to OCaml, letting List.length l be written l::length and List.map (fun e -> e + 1) l written like l::map (fun e -> e + 1)?
This was asked by Fabrice Le Fessant on the ocaml bugtracker a few months ago: PR#6012 object-like notation for module functions, inspired by his work on the wxOCaml library (see thee design description in this PDF).
The feature request generated a discussion (go see the PR#6012 link for the discussion), but I think the consensus is that it's not such a good idea. People were not happy with adding a specific language feature to support making module programming similar to object programming.
I think you could break down this idea into smaller pieces that are each interesting in isolation, but would need much more work to be well-understood enough to be intregrated in a mature programming language. You're hinting at some form of code inference, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With