| | 1 | = Brief explanation = |
| | 2 | |
| | 3 | Suppose we have |
| | 4 | {{{ |
| | 5 | module M where |
| | 6 | import Data.List |
| | 7 | nub x = x |
| | 8 | foo y = nub y |
| | 9 | }}} |
| | 10 | The program is rejected because the occurrence of `nub` in `foo` is ambiguous. This is sometimes tiresome: a new import can force you to add extra `M.nub` qualifiers. |
| | 11 | |
| | 12 | An obvious alternative is that '''local declarations shadow imports''', so an unqualified name means the locally-defined one. (A warning flag could tell you if you were using this ability.) This is entirely consistent with shadowing in expressions -- except that you can still access at the imported thing with a qualified name. |
| | 13 | |
| | 14 | It's not a big thing, but unless I've missed something, it seems to me that this would make the language more consistent (by treating shadowing consistently), more convenient; and of course it's completely backward compatible. |
| | 15 | |
| | 16 | == Proposal == |
| | 17 | |
| | 18 | Local declarations shadow imports. |
| | 19 | |
| | 20 | == Remarks == |
| | 21 | |
| | 22 | This is a modest change. But it is a change, so only worth making if there is significant support (rather than merely absence of opposition). |