Default class members require imports for their implementation
When a class member is a macro, a module importing that member needs to import the definitions from its implementation, which is logical. The same restriction now appears on default class members, however, and I don't think that is necessary. Consider the example below. Since Start
uses the instance of []
there is no need for reverse
to be present in test
, but this is still required by the import system:
Error [test.icl,2,import]: function/macro reverse not imported
I think that the imports are only needed if the importing module contains an instance of the class that uses the default class member.
test.icl:
module test
from cls import class children(..), instance children []
Start = children_from_left [1,2,3]
cls.dcl:
definition module cls
from StdList import reverse
class children m
where
children_from_left :: (m a) -> [a]
children_from_left x = reverse (children_from_right x)
children_from_right :: (m a) -> [a]
children_from_right x = reverse (children_from_left x)
instance children []
cls.icl:
implementation module cls
instance children [] where children_from_left xs = xs