Module resolution on pack (~/lib/swipl/pack)

Is this normal or bug on module resolution under ~/lib/swipl/pack ?
I spent some time on this confusion but only to fail.
I might still miss some basics on module.

*** begin of testundef.pl ***
:- module(testundef, []).
aaa :- bbb.
user:bbb:- writeln(hello).
*** end of testundef.pl ***

  1. Under the directory, for example, ~/Desktop
    (but not under ~/lib/swipl/pack),this works as expected:
    ?- use_module(misc(testundef)).
    ?- testundef:aaa.
    hello
    true.

However, the following 2 causes error.
2. Putting the same code at ~/lib/swipl/pack/pac/prolog/misc/testundef.pl

% swipl
?- use_module(library(pac)).
true.

?- use_module(misc(testundef)).
true.

?- testundef:aaa.
ERROR: Undefined procedure: testundef:bbb/0
ERROR: However, there are definitions for:
ERROR: bbb/0
false.

Any help much appreciated.

Kuniaki Mukai

This is not an answer to any part of your question but a suggestion on formatting.

This site uses markdown which can format Prolog source code.

To use the Prolog formatting on the line before the source code add (```prolog) and after the last line add the line (```)

e.g.

```prolog
Prolog source code
```

Without markdown

test :-
something(A,B,C),
foo(Bar).

With markdown

test :-
   something(A,B,C),
   foo(Bar).

:slightly_smiling_face:

Thank you for instruction on module. However,

my question is on how swi puts a module prefix

on c like in a sample below which is not defined in module a.

I thought a prefix ‘user’ should be put on when c is

defined in user, but it seems that a (not user) is put in stead when

the module source is put below the pack directry, in spite

of c beging defined in 'user’.

Of course I know that the directory is not supposed

to be accessed by the user without

the package handler (pack_install use_module, …).

So it is natural to imagine some spcial rule on module resolution

is applied to packages under the directory swipl/pack.

I am sure on it, so I am asking.


:- module(a, []).
b :- c.

Thank you also for instruction on formatting.

Kuniaki Mukai

With regards to formatting. In the example the parens should not be added, it should just be

```prolog
Put prolog code here
```

Also you can go back and edit something your wrote by click on the pencil icon.

With regards to your question, I have never used pack so can’t help.

Thanks,

I have a swi package ‘pac’ folder which locally is

“relocatable” using prolog_load_context/2. I learned

it in the manual, which is really useful as the manual says.

However relocatability breaks because of the undefined error

exceptionally when it is installed under ~/lib/swipl/pack by pack_install/1,

neither for manually installed. I am curious on the why.

A version of qualified goal works already to for a upgrade, but

I am inclined to insist on a version of unqualified goal version, because

I heard that in general unqualified goal version is recommended

as prolog programming wit modules.

Kuniaki Mukai