Vip 7.302 issue with findall and [ || ]

Discussions related to Visual Prolog
Matthias Greving
Posts: 18
Joined: 21 Mar 2002 0:01

Vip 7.302 issue with findall and [ || ]

Unread post by Matthias Greving » 8 Jul 2010 12:58

Hello,

I have converted an old project into a vip7.3 one and stumbled over this issue. In this case findall and the [ || ] construct only find the first item of a list.

Here is an example:

Code: Select all

facts   tt : (string) nondeterm. clauses   tt("1").   tt("2").   tt("3").   predicates   getTT : () -> string_list. clauses   getTT() = TT :-     findall(T, tt(T), TT),     !.   predicates   getTT2 : () -> string_list. clauses   getTT2() = TT :-     findall(T, tt(T), TT),     _ = list::length(TT),     !.   predicates   getTT3 : () -> string_list. clauses   getTT3() = TT :-     TT = [T || tt(T)],     !.   predicates   getTT4 : () -> string_list. clauses   getTT4() = TT :-     TT = [T || tt(T)],     _ = list::length(TT),     !.   predicates     onTestsFindall : window::menuItemListener. clauses     onTestsFindall(_Source, _MenuTag):-       stdio::write("Test 1\n"),       TT = getTT(),       stdio::write(TT, "\n"),       stdio::write("Test 2\n"),       TT2 = getTT2(),       stdio::write(TT2, "\n"),       stdio::write("Test 3\n"),       TT3 = getTT3(),       stdio::write(TT3, "\n"),       stdio::write("Test 4\n"),       TT4 = getTT4(),       stdio::write(TT4, "\n"),       !.
This code results into this result:

Test 1
["1"]
Test 2
["1","2","3"]
Test 3
["1"]
Test 4
["1","2","3"]

I suppose this is a bug in the compiler, in the older vip versions the code worked.
The additional _ = list::length is only my workaround, do you have a better solution?

Regards
Matthias

User avatar
Thomas Linder Puls
VIP Member
Posts: 2450
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 8 Jul 2010 14:49

Thank you. It is clearly a compiler bug.

The best solution for you right now is to remove the cuts in the end of the clauses. They serve no purpose and apparently cause this bug.

Code: Select all

predicates   getTT : () -> string_list. clauses   getTT() = TT :-     findall(T, tt(T), TT).
Regards Thomas Linder Puls
PDC

Matthias Greving
Posts: 18
Joined: 21 Mar 2002 0:01

Unread post by Matthias Greving » 8 Jul 2010 15:22

Hello Thomas,

thank you, your solution works for me too. It is much more elegant than my workaround.
I use the cut for most predicates, just one of my bad habits.

mfg
Matthias

Roland Soltysiak
Active Member
Posts: 39
Joined: 5 Jul 2000 23:01

Unread post by Roland Soltysiak » 6 Oct 2010 12:54

Hello Thomas,

will there be a patch for this bug soon?

The work around would be a lot of additional work for me.

Thanks

Roland

User avatar
Thomas Linder Puls
VIP Member
Posts: 2450
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 8 Oct 2010 12:21

There have also been a few other issues, so we will make a patch next week.
Regards Thomas Linder Puls
PDC

Roland Soltysiak
Active Member
Posts: 39
Joined: 5 Jul 2000 23:01

Unread post by Roland Soltysiak » 8 Oct 2010 12:36

Thanks,Thomas.

:D

Post Reply