trealla icon indicating copy to clipboard operation
trealla copied to clipboard

Mysterious module switchover

Open flexoron opened this issue 2 years ago • 6 comments

 $ tpl
Trealla Prolog (c) Infradig 2020-2022, v2.7.6
?- listing.
   true.

?- length(X,X).
   error(resource_error(finite_memory),length/2).

?- listing.
:-module(lists,[member/2,memberchk/2,select/3,selectchk/3,append/2,append/3,subtract/3,union/3,intersection/3,is_set/1,nth1/3,nth0/3,nth1/4,nth0/4,last/2,flatten/2,same_length/2,sum_list/2,prod_list/2,max_list/2,min_list/2,list_to_conjunction/2,conjunction_to_list/2,numlist/3,length/2,reverse/2]).
:-module(lists,[member/2,memberchk/2,select/3,selectchk/3,append/2,append/3,subtract/3,union/3,intersection/3,is_set/1,nth1/3,nth0/3,nth1/4,nth0/4,last/2,flatten/2,same_length/2,sum_list/2,prod_list/2,max_list/2,min_list/2,list_to_conjunction/2,conjunction_to_list/2,numlist/3,length/2,reverse/2]).
member(A,[A|B]).
member(A,[B|C]) :- member(A,C).
memberchk(A,B) :- member(A,B),! .
select(A,[A|B],B).
select(A,[B|C],[B|D]) :- select(A,C,D).
selectchk(A,B,C) :- select(A,B,C),! .
: 
: 
: 
length_rundown([A|B],C) :- D is C-1,length_rundown(B,D).
   true.
?-

Is this OK?

Also, please note: ?- listing :-module(lists, ... :-module(lists, ... :

flexoron avatar Dec 19 '22 01:12 flexoron

$ ./tpl
Trealla Prolog (c) Infradig 2020-2022, v2.7.10

?- [user].
member(x,x).
   true.
?- member(X,Y).
   X = x, Y = X.
?- member(x,x).
   true.

?- length(X,X).
   error(resource_error(finite_memory),length/2).

?- member(X,Y).
   Y = [X|_A]
;  Y = [_A,X|_B]
;  Y = [_A,_B,X|_C]
;  ... .
?- member(x,x).
   false.

?- halt.

flexoron avatar Dec 20 '22 11:12 flexoron

You have defined user:member/2 that overrides lists:member/2 in the first couple of queries.

On Tue, Dec 20, 2022 at 9:18 PM flexoron @.***> wrote:

$ ./tpl Trealla Prolog (c) Infradig 2020-2022, v2.7.10

?- [user]. member(x,x). true. ?- member(X,Y). X = x, Y = X. ?- member(x,x). true.

?- length(X,X). error(resource_error(finite_memory),length/2).

?- member(X,Y). Y = [X|_A] ; Y = [_A,X|_B] ; Y = [_A,_B,X|_C] ; ... . ?- member(x,x). false. ?- halt.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/88#issuecomment-1359205283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEV5XMFQWZ52WVCGNC3WOGI2BANCNFSM6AAAAAATC24CRQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

infradig avatar Dec 20 '22 12:12 infradig

Well calling length/2 does an import on module lists which brings in lists:member/2 which seem to be silently replacing users:member/2. Unusual I suppose.

On Tue, 20 Dec 2022, 21:18 flexoron, @.***> wrote:

$ ./tpl Trealla Prolog (c) Infradig 2020-2022, v2.7.10

?- [user]. member(x,x). true. ?- member(X,Y). X = x, Y = X. ?- member(x,x). true.

?- length(X,X). error(resource_error(finite_memory),length/2).

?- member(X,Y). Y = [X|_A] ; Y = [_A,X|_B] ; Y = [_A,_B,X|_C] ; ... . ?- member(x,x). false. ?- halt.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/88#issuecomment-1359205283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEV5XMFQWZ52WVCGNC3WOGI2BANCNFSM6AAAAAATC24CRQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

infradig avatar Dec 20 '22 13:12 infradig

This time without length/2.

$ tpl
?- is_set([\\,\]).
   true.
?- listing.
   true.

?- is_set([\\,\\]).
   false.
?- listing.
:-module(lists,[member/2,memberchk/2,select/3,selectchk/3,append/2,append/3,subtract/3,union/3,intersection/3,is_set/1,nth1/3,nth0/3,nth1/4,nth0/4,last/2,flatten/2,same_length/2,sum_list/2,prod_list/2,max_list/2,min_list/2,list_to_conjunction/2,conjunction_to_list/2,numlist/3,length/2,reverse/2]).
: 
: 
  true.

?- trace, is_set([\\,\\]).
[lists:1] EXIT trace
[lists:3] CALL is_set([\\,\\])
[lists:5] CALL '$skip_max_list'(_0,_5,[\\,\\],_2)
[lists:7] EXIT '$skip_max_list'(2,_5,[\\,\\],[])
[lists:9] EXIT '$skip_list'(2,[\\,\\],[])
[lists:11] CALL []== []
[lists:13] EXIT []== []
[lists:15] CALL sort([\\,\\],_3)
[lists:17] EXIT sort([\\,\\],[\\])
[lists:19] CALL '$skip_max_list'(_8,2,[\\],_11)
[lists:21] EXIT '$skip_max_list'(1,2,[\\],[])
[lists:23] CALL !
[lists:25] EXIT !
[lists:27] CALL []== []
[lists:29] EXIT []== []
[lists:31] CALL !
[lists:33] EXIT !
[lists:35] CALL 2=1
[lists:37] FAIL 2=1
   false.
?- 

flexoron avatar Dec 20 '22 21:12 flexoron

Failure is leaving the current module as lists.

?- is_set([\,]). true. ?- module(M). M = user. ?- is_set([\,\]). false. ?- module(M). M = lists. ?- module(user). true. ?- listing. true.

Is this good or bad? Probably bad.

On Wed, Dec 21, 2022 at 7:41 AM flexoron @.***> wrote:

This time without length/2.

?- is_set([\,]). true. ?- listing. true.

?- is_set([\,\]). false. ?- listing. :-module(lists,[member/2,memberchk/2,select/3,selectchk/3,append/2,append/3,subtract/3,union/3,intersection/3,is_set/1,nth1/3,nth0/3,nth1/4,nth0/4,last/2,flatten/2,same_length/2,sum_list/2,prod_list/2,max_list/2,min_list/2,list_to_conjunction/2,conjunction_to_list/2,numlist/3,length/2,reverse/2]). : : true.

?- trace, is_set([\,\]). [lists:1] EXIT trace [lists:3] CALL is_set([\,\]) [lists:5] CALL '$skip_max_list'(_0,_5,[\,\],_2) [lists:7] EXIT '$skip_max_list'(2,_5,[\,\],[]) [lists:9] EXIT '$skip_list'(2,[\,\],[]) [lists:11] CALL []== [] [lists:13] EXIT []== [] [lists:15] CALL sort([\,\],_3) [lists:17] EXIT sort([\,\],[\]) [lists:19] CALL '$skip_max_list'(_8,2,[\],_11) [lists:21] EXIT '$skip_max_list'(1,2,[\],[]) [lists:23] CALL ! [lists:25] EXIT ! [lists:27] CALL []== [] [lists:29] EXIT []== [] [lists:31] CALL ! [lists:33] EXIT ! [lists:35] CALL 2=1 [lists:37] FAIL 2=1 false. ?-

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/88#issuecomment-1360354660, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEURNQ6J7BURE2APVATWOIRYPANCNFSM6AAAAAATC24CRQ . You are receiving this because you commented.Message ID: @.***>

infradig avatar Dec 21 '22 03:12 infradig

Probably a question of feature documentation? v2.7.11

?- [user].
member(x,x).
   true.

?- is_set([x,x]); member(A,B).
   A = x, B = A.
?- module(M).
   M = user.

?- is_set([x,x]). member(A,B). listing(member). % Full-Stop is a Half-Stop is a Feature?
   B = [A|_A]                                   % Somehow unexpected ...
;  ... .
member(A,[A|B]).                                
member(A,[B|C]) :- member(A,C).
   true.
?- module(M).                                     
   M = lists.                                    % ... or a feature

?- halt.

or

$ tpl
Trealla Prolog (c) Infradig 2020-2022, v2.7.11

?- module(M).
   M = user.

?- is_set([x,x]). false.
   false.
?- module(M).
   M = user.

?- is_set([x,x]). true.
   true.
?- module(M).
   M = lists. % unexpected feature

?- halt.

flexoron avatar Dec 21 '22 13:12 flexoron