Changes between Initial Version and Version 1 of ImportShadowing


Ignore:
Timestamp:
Oct 14, 2008 8:17:28 AM (7 years ago)
Author:
simonpj@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ImportShadowing

    v1 v1  
     1= Brief explanation =
     2
     3Suppose we have
     4{{{
     5module M where
     6      import Data.List
     7      nub x = x
     8      foo y = nub y
     9}}}
     10The 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
     12An 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
     14It'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
     18Local declarations shadow imports.
     19
     20== Remarks ==
     21
     22This is a modest change.  But it is a change, so only worth making if there is significant support (rather than merely absence of opposition).