[clean-list] question about implicit imports of definition
Arjen van Weelden
A.vanWeelden at cs.ru.nl
Mon Dec 11 10:52:33 MET 2006
Jigang Sun wrote:
> I am studying Clean module system. What I know is that function definition can be pass-through (downwards) via definition module by importing. For example,
>
> definition module aa
> import StdEnv
>
> implementation module aa
> //empty body
>
> //Start module
> module try
> import aa
>
> Start = (+) 1 2
>
> works OK.
>
> But I found imported definitions could not be passed horizontally to corresponding implementation module as showed by the following example. StdEnv is imported in definition module aa, in implementation module aa I turned off "import StdEnv", then "Error [aa.icl,4,]: + undefined" error message is given.
>
> definition module aa
> import StdEnv
> add2 :: Int Int -> Int
>
> implementation module aa
> //import StdEnv
> add2 ::Int Int -> Int
> add2 x y = x+y //line 4, + is considered undefined
>
>
> module try //Start module
> import aa
>
> Start = add2 1 2
>
> I wonder if definitions imported into a definition module should be available to its corresponding implemtation module?
>
> Thanks.
> Jigang
>
The current Clean compiler does not automatically include imports from a
definition module into an implementation module. You are observing
correct behavior.
You are not the only one who finds this counter-intuitive, confusing,
and/or inconvenient. IIRC, one can construct examples where this is
useful, but these tend to be extreme cases IMHO. The current behavior is
a bit like C, and maybe we should expect a little more from a
higher-level language. :-)
kind regards,
Arjen
More information about the clean-list
mailing list