[Ur] last type decl wins?

Vag Vagoff vag.vagoff at gmail.com
Sat Apr 16 05:19:23 EDT 2011


On 13.04.2011 4:13, Adam Chlipala wrote:
> Marc Weber wrote:
>> Should this be rejected?
>>
>> You can put this into a .ur file top level and still compile it!?
>>
>> type type_int = int
>> val y:type_int = 2
>> type type_int = string
>> val x:type_int = "o"
>>
>> type_int is assigned int and string!
>>
>> Or am I totally missunderstanding something here?
>
> This behavior is just as in ML or Haskell. You are shadowing a definition, but the old definition doesn't "go away," it just becomes impossible to reference. At the end of the file, [y] has a type that refers to an out-of-scope identifier, but that isn't problematic semantically.

No, in Haskell you can shadow only by local (let or where) definitions, not top level.
There is,
  - toplevel definition in current module clashes with any imported definitions (there is why "hiding" is used)
  - toplevel definition in current module clashes with other toplevel definitions in current module

Vag.



More information about the Ur mailing list