[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Original naming
Original-Via: uk.ac.st-and.cs; Wed, 28 Nov 90 17:15:26 GMT
From: "David J. McNally" <djm@cs.st-and.ac.uk>
Date: Wed, 28 Nov 90 14:18:55 GMT
To: haskell@cs.glasgow.ac.uk
Subject: Original naming
Sender: haskell-request@cs.glasgow.ac.uk
Haskell defines two entities to be the same if they have the same original
name. An original name is a pair consisting of the name of the module
in which the entity was declared and the name it was given in that declaration.
By name, I am assuming that the report means the sequence of characters making up the name of the module/entity i.e modid, varid etc.
Consider the following example :
module A where
data T = X Bool
in one "file"
module B(f) where
import A
f (X b) = b
in another "file"
module Main where
import A
import B
main resps = [ AppendChan stdout (show (f (X True))) ]
these three modules can be compiled separately in the order given above and
yield an executable program as a result which behaves as expected. Now consider a new implementation of module A :-
module A where
data T = X Int
which is compiled separately .... no problem so far ...
now we can define a new Main :-
module Main where
import A
import B
main resps = [ AppendChan stdout (show (f (X 3))) ]
which should compile correctly yielding an executable program. Why?
Because T has the same original name in both the original implementation
of A and the new one - namely ("A","T") so function f can be applied to
objects of this type regardless of which A they come from. The result
is that objects of any type can effectively be turned into objects of
another type. That is, the system is not type safe. The reason this happens
is that module A is being updated which invalidates referential transparency.
The language semantics depend on the order of evaluation (compilation!).
A makefile could of course be used to resolve such problems, but do we really want to appeal to an external manager to solve this problem.
Another solution is to make the two A's have different original names e.g. with a time of modification stamp attached to the module name. This yields type safety, but this no longer allows the implementation of an interface to be
modified without invalidating all its users.
Have these problems occurred to the language designers? If so, what do
they propose to do about them?
Dave McNally
Richard Connor