fsharp / fsharp/fslang-suggestions
Allow the definition of extension methods in a namespace
- Dominant language
- No language data
- Stars
- 373
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
I propose we allow the definition of extension methods in namespaces.
The existing way of approaching this problem in F# is to put the extension methods in a module, perhaps with the ``[]`` attribute to reduce friction for the user.
This approach is used because extension methods compile as static methods in a static class, and the F# 2.0 design took the "WYSIWYG" approach where an implicitly created module in a namespace felt odd.
However, in F# 4.x this seems somehow seems less odd, especially since ``[]`` can already been used to get much the same effect.
## Pros and Cons
The advantage of making this adjustment to F# are orthogonality
The disadvantage of making this adjustment to F# is that the extensions will end up in a module with an implicit name, and we need a rule to decide that name in a stable way.
## Extra information
Estimated cost (XS, S, M, L, XL, XXL): M
## Affidavit (please submit!)
Please tick this by placing a cross in the box:
* [x] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue
* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate
Please tick all that apply:
* [x] This is not a breaking change to the F# language design
* [x] I or my company would be willing to help implement and/or test this
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.