weird load behavior

Help requests on developing Logtalk applications

Moderator: Paulo Moura

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

weird load behavior

Post by shengcer » Thu Aug 15, 2013 9:32 pm

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: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura » Thu Aug 15, 2013 11:06 pm

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 » Thu Aug 15, 2013 11:42 pm

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: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura » Thu Aug 15, 2013 11:55 pm

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 » Fri Aug 16, 2013 1:40 am

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: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: weird load behavior

Post by Paulo Moura » Fri Aug 16, 2013 1:54 am

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 » Fri Aug 16, 2013 2:13 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest