libcellml icon indicating copy to clipboard operation
libcellml copied to clipboard

Importer: the path parameter for `resolveImports()` should be optional

Open agarny opened this issue 5 years ago • 3 comments

Right now, we can resolve imports without providing a key as such (in case a model only exists in memory, it would seem). We do this by passing resolveImports() an empty string:

importer->resolveImports(model, ""); 

while, ideally, we would be able to just skip the parameter, i.e. have something like:

importer->resolveImports(model);

agarny avatar Aug 05 '20 04:08 agarny

One reason for the Importer class' existence is so that we don't end up importing an instance of a model multiple times. In order for that to be possible, you have to store it somehow and be able to reference it later on; it needs a key. The second parameter to the resolveImports function is the path, not the key.

If others are happy with overloading the resolve function so that it doesn't need an input when the path is blank, I'm happy to do that ... just wanted to be clear it's unrelated to the key thing.

kerimoyle avatar Aug 05 '20 04:08 kerimoyle

My bad, the path indeed.

agarny avatar Aug 05 '20 04:08 agarny

Resolving imports can only be done when defining the context in which import paths should be evaluated. The only case in which providing no context makes sense is when all import URLs will be defined as absolute URLs. Requiring the base context to be defined requires the user to understand what they are doing and I personally have found it very useful in other packages to be forced to read the docs as to what that second argument should be.

nickerso avatar Aug 05 '20 04:08 nickerso