Type prefixes vs. qualification (Was: System.FilePath propsal)

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Tue Nov 2 03:54:07 EST 2004


Henning Thielemann wrote:

>  I really advise to take a look at Modula-3. There, not only every
> function name omits the information of the type, even more each module has
> the name of the type it describes and the main type has the name T. 

Indeed this is a useful convention.

If we mainly use unqualified imports,
then we probably want  module Foo where data Foo = ...

but indeed larger projects sort of require qualified imports.
but this leads to strange code like  x :: Foo.Foo
Where it really looks better to have
module Foo where data Type = ..
as this allows  import qualified Foo ; x :: Foo.Type

You know where this leads to? Like, Java. There, a module
(class) automaticall contains a data declaration,
and from the outside it is just accesed by module name
(i. e., omitting the ".Type" suffix from the above example).

Not a bad thing, IMHO. It's generally a good idea
to structure the code (functions) according to the structure of data,
and to keep data declarations separate from each other
(i. e., each in their own module).

Best regards,
-- 
-- Johannes Waldmann,  Tel/Fax: (0341) 3076 6479 / 6480 --
------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------



More information about the Libraries mailing list