weird load behavior

Help requests on developing Logtalk applications

Moderator: Paulo Moura

Locked
shengcer
Posts: 21
Joined: Wed Aug 14, 2013 7:54 pm

weird load behavior

Post by shengcer »

I started to push lots of prolog code towards logtalk3, but got this weird behavior as shown below. I had to load multiple times until the ERRORs were eventually gone and everything finally got loaded

Code: Select all

ERROR: /home/shengcer/food/.lgt_tmp/load.pl:5: Initialization goal raised exception:
ERROR: directory `/home/shengcer/food/fruits/fruits/.lgt_tmp/' does not exist
I put code into 2 sub folders, i.e., fruits and desserts, loader file is like this,

Code: Select all

:- initialization((
  shell('touch load.lgt'),
  logtalk_load([
    'fruits/apple.lgt',
    'fruits/orange.lgt',
    'fruits/banana.lgt',
    'dessert/cake.lgt',
    'dessert/chocolate.lgt'
  ])
)) .

Paulo Moura
Logtalk developer
Posts: 533
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura »

What if you comment out the call to the shell/1 predicate?
Paulo Moura
Logtalk developer

shengcer
Posts: 21
Joined: Wed Aug 14, 2013 7:54 pm

Re: weird load behavior

Post by shengcer »

No, that won't help :-( I do notice seems like if I put everything in the same path, the load file will just be loaded fine.
Paulo Moura wrote:What if you comment out the call to the shell/1 predicate?

Paulo Moura
Logtalk developer
Posts: 533
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura »

I just reproduced the problem. But only when using either B-Prolog or SWI-Prolog as the backend compilers. Looking into it. More later. An workaround for now is to write something like:

Code: Select all

:- initialization((
    logtalk_load_context(directory, Directory),
    assertz(logtalk_library_path(base, Directory)),
    assertz(logtalk_library_path(fruits, base('fruits/'))),
    assertz(logtalk_library_path(desserts, base('desserts/')))
)).

:- initialization((
    logtalk_load([
        fruits(apple),
        fruits(orange),
        fruits(banana),
        desserts(cake),
        desserts(chocolate)
    ])
)) .
Paulo Moura
Logtalk developer

shengcer
Posts: 21
Joined: Wed Aug 14, 2013 7:54 pm

Re: weird load behavior

Post by shengcer »

Paulo - Thanks. I will give it a try tomorrow. I am using SWI-Prolog.
Paulo Moura wrote:I just reproduced the problem. But only when using either B-Prolog or SWI-Prolog as the backend compilers. Looking into it. More later. An workaround for now is to write something like:

Code: Select all

:- initialization((
    logtalk_load_context(directory, Directory),
    assertz(logtalk_library_path(base, Directory)),
    assertz(logtalk_library_path(fruits, base('fruits/'))),
    assertz(logtalk_library_path(desserts, base('desserts/')))
)).

:- initialization((
    logtalk_load([
        fruits(apple),
        fruits(orange),
        fruits(banana),
        desserts(cake),
        desserts(chocolate)
    ])
)) .

Paulo Moura
Logtalk developer
Posts: 533
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura »

The bug is now fixed in the latest git version when using B-Prolog or SWI-Prolog as the backend compilers.
Paulo Moura
Logtalk developer

shengcer
Posts: 21
Joined: Wed Aug 14, 2013 7:54 pm

Re: weird load behavior

Post by shengcer »

Thanks - it is good now.
Paulo Moura wrote:The bug is now fixed in the latest git version when using B-Prolog or SWI-Prolog as the backend compilers.

Locked