TurkishCharacterProblem

Hi,

In our study, we use version 5.6.61 of the SWI-Prolog.
However, this version does not accept/support some Turkish characters (ş, ç… etc.) and creates problems. What can we do about it? What solutions can you offer us?

Thank you for your help
Best regards

Upgrade? 5.6.61 is quite old. Current stable version is 8.0.3.

1 Like

You made me look it up :slight_smile:

$ git show V5.6.61
tag V5.6.61
Tagger: Jan Wielemaker <J.Wielemaker@uva.nl>
Date:   Thu Sep 25 21:33:49 2008 +0200

Release tag for 5.6.61

If it was a kid in Finland it would be now going to the 6th grade in school but hopefully not drinking yet.

5.6 i indeed really old. I think it already did Unicode, but I’m not sure. Te other question is what OS. Non-US-ASCII handling differs quite a bit between te supported operating systems.

We are aware of new versions of the prolog. But we use Attribute Logic Engine.
ALE is a very old logic programming system. (2001)

It developed under: SICStus Prolog, Version 3.8.6
Ported to: SWI Prolog, Version 4.0.11
Updated for: SWI Prolog, Version 5.6.47

That’s why we need a older version. It can only work in accordance with the oldest versions of the prolog.

It should be relatively straight-forward to make sure it works with the latest stable version of SWI-Prolog. A very precursory look at this file here doesn’t show anything too scary. You might even get rid of some (all?) of the “SWI patch code” at the top of the file.

PS: Someone please correct me but I have been under the impression that compatibility between Prolog implementations hasn’t gotten worse in the last 10 years?

I think that is an issue with several dimensions. SWI-Prolog got the dialect emulation infra structure. A bit of synergy emerged from the short-lived Prolog Commons initiative. SWI-Prolog and ECLiPSe synchronized support for strings and partly synchronized ISO extensions dealing with floats. SWI-Prolog got a lot of XSB’s tabling and and an ongoing implementation of the XSB emulation. I don’t know how much other systems copied from SWI-Prolog. Maybe Paulo has a clue. SWI-Prolog also gots its dicts and string more close to its core which breaks some compatibility.

Virtually all systems now have :- if(..) and a widely supported way to detect the Prolog dialect you are running. This allows writing code that runs on mutiple systems in a fairly supported way.

For this project (ALE), SWI-Prolog’s SICStus emulation might do most of the job. Best would be to fill the missing bits of the emulation so you can use SICStus and SWI on the same source.

After downloading the file, adding as first line:

:- module(ale, []).

and changing (1) all calls to the deprecated current_predicate/2 predicate to current_predicate /1 and (2) all calls to the deprecated assert/1 predicate to assertz /1 (to cut down the number of errors and warnings), compiling with Logtalk to take advantage of its linter, I get:

?- logtalk_compile('ale.swi.pl').
*     Unknown predicate called but not defined: (sub)/2
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 1350-1357
*     
*     
...
% [ /Users/pmoura/Desktop/ale.swi.pl compiled ]
% 296 compilation warnings
true.

Most of these warnings are very easy to fix as the solutions are printed with the warning. I created a gist with the changes I mentioned above:

I also created a gist with the linter warnings as there are too many to paste here:

@filiz Enjoying patching :stuck_out_tongue: I suggest you start by adding the missing dynamic/1 directives to further cut down the number of warnings.

P.S. Just updated the gists after adding the missing dynamic/1 and use_module/2 directives.

1 Like

Compiling with the Logtalk linter portability flag turned on (but with most of the other lint flags turned off; see warnings gist for those warnings):

?- logtalk_compile('ale.swi.pl').
*     Prolog dialect rewrite of term :-module(ale,[]) as [(:-module(ale,[]))]
*       while compiling file
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 2
*     
*     Prolog dialect rewrite of term :-use_module(library(backcomp),[merge/3,set_feature/2]) as :-use_module(backward_compatibility,[merge/3,set_feature/2])
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 48
*     
*     Prolog dialect rewrite of term :-use_module(library(lists),[append/3,member/2,reverse/2]) as :-use_module(lists,[append/3,member/2,reverse/2])
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 49
*     
*     Prolog dialect rewrite of term :-use_module(library(ugraphs),[top_sort/2,vertices_edges_to_ugraph/3]) as :-use_module(ugraphs,[top_sort/2,vertices_edges_to_ugraph/3])
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 50
*     
*     Prolog dialect rewrite of term :-ensure_loaded(library(quintus)) as :-use_module(quintus,[tan/2,unix/1,atom_char/2,midstring/6,date/1,genarg/3,asin/2,ceiling/2,cos/2,raise_exception/1,midstring/3,otherwise/0,prolog_flag/2,sqrt/2,acos/2,pow/3,log10/2,mode/1,sin/2,on_exception/3,skip_line/1,midstring/4,stream_position/3,skip_line/0,simple/1,sign/2,round/2,atan/2,log/2,abs/2,compile/1,midstring/5,current_stream/3,no_style_check/1,atan2/3,floor/2])
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 1067
*     
*     Compiling query as an initialization goal: set_feature(character_escapes,true)
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 1100
*     
*     Compiling query as an initialization goal: nl,write('\nALE Version 3.2.1; December, 2001\nCopyright (C) 1992-1995, Bob Carpenter and Gerald Penn\nCoopyright (C) 1998,1999,2001, Gerald Penn\t   \nAll rights reserved'),nl,nointerp,nosubtest,parse,assertz(lexicon_consult)
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 7780-7788
*     
*     No matching clause for goal: subsume([s(A,B,C,D)],E,F,<,>,G,H,[],[])
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 7822-7827
*     
*     Call to non-standard Prolog built-in predicate: consult/1
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 1070-1071
*     
*     Call to non-standard Prolog built-in predicate: memberchk/2
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 1133-1136
*     
*     Call to non-standard Prolog built-in predicate: name/2
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 2075-2080
*     
*     Call to non-standard Prolog built-in predicate: length/2
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 2411-2418
*     
*     Call to non-standard Prolog built-in predicate: break/0
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 3093-3095
*     
*     Call to non-standard Prolog built-in predicate: abort/0
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 3105-3106
*     
*     Call to non-standard Prolog built-in predicate: prolog_load_context/2
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 5012-5017
*     
*     Call to non-standard Prolog built-in predicate: absolute_file_name/3
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 5096-5109
*     
*     Call to non-standard Prolog built-in predicate: ttyflush/0
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 5794-5803
*     
*     Call to non-standard Prolog built-in predicate: tab/1
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 6497-6500
*     
*     Call to non-standard Prolog built-in predicate: telling/1
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 7312-7318
*     
*     Call to non-standard Prolog built-in predicate: tell/1
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 7312-7318
*     
*     Call to non-standard Prolog built-in predicate: told/0
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl between lines 7312-7318
*     
% [ /Users/pmoura/Desktop/ale.swi.pl compiled ]
% 21 compilation warnings
true.

You also get a lot of warnings from SWI-Prolog itself … Some of these may not be a real problem as (for example) the predicates are defined at runtime using assert/1 before being called.

swipl ale.swi.pl 
Warning: /home/jan/ale.swi.pl:2776:
Warning:    Singleton variable in branch: KPair
Warning: /home/jan/ale.swi.pl:3478:
Warning:    Singleton variable in branch: Ref


ALE Version 3.2.1; December, 2001
Copyright (C) 1992-1995, Bob Carpenter and Gerald Penn
Coopyright (C) 1998,1999,2001, Gerald Penn	   
All rights reserved

interpreter is inactive

edge/empty category subsumption checking inactive

compiler will produce code for parsing only
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.20-44-gcb25bef5c)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

    CMake built from "/home/jan/src/swipl-devel/linux"

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

101 ?- make.
% Updating index for library /home/jan/.config/swi-prolog/lib/
% Updating index for library /home/jan/src/swipl-devel/linux/home/library/
% Updating index for library /home/jan/src/swipl-devel/linux/home/xpce/prolog/lib/
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning: 
Warning: +++>/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5977:30: 1-st clause of compile_fun/2
Warning: 	/home/jan/ale.swi.pl:3274:3: 14-th clause of if_b/2
Warning: --->/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:7501:3: 16-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:3590:3: 9-th clause of if_h/1
Warning: add_to_type/5, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2188:5: 11-th clause of add_to/5
Warning: approp/3, which is referenced by
Warning: 	/home/jan/ale.swi.pl:1565:24: 1-st clause of approp_feats/2
Warning: 	/home/jan/ale.swi.pl:1556:25: 1-st clause of approps/2
Warning: 	/home/jan/ale.swi.pl:4425:18: 7-th clause of compile_desc/12
Warning: 	/home/jan/ale.swi.pl:4528:18: 7-th clause of compile_desc/13
Warning: 	/home/jan/ale.swi.pl:5359:33: 2-nd clause of compile_ext_sub_assert/0
Warning: 	/home/jan/ale.swi.pl:4875:16: 2-nd clause of compile_pathval/7
Warning: 	/home/jan/ale.swi.pl:4894:16: 2-nd clause of compile_pathval/8
Warning: 	/home/jan/ale.swi.pl:7330:2: 1-st clause of feat_cycle2/5
Warning: 	/home/jan/ale.swi.pl:7333:2: 2-nd clause of feat_cycle2/5
Warning: 	/home/jan/ale.swi.pl:1127:24: 1-st clause of top_sort/5
Warning: check_post_traverse/5, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2442:2: 1-st clause of traverseQ/7
Warning: check_pre_traverse/6, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2387:2: 1-st clause of ext_act/4
Warning: check_sub_seq/5, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2500:21: 2-nd clause of check_inequal_conjunct/3
Warning: cons/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5410:19: 1-st clause of compile_cons/2
Warning: 	/home/jan/ale.swi.pl:5412:33: 1-st clause of compile_cons/2
Warning: 	/home/jan/ale.swi.pl:5415:18: 1-st clause of compile_cons/2
Warning: 	/home/jan/ale.swi.pl:5419:24: 1-st clause of compile_cons/2
Warning: 	/home/jan/ale.swi.pl:1809:2: 2-nd clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:1817:2: 3-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:1402:5: 1-st clause of immed_cons/2
Warning: 	/home/jan/ale.swi.pl:1402:37: 1-st clause of immed_cons/2
Warning: 	/home/jan/ale.swi.pl:6171:8: 1-st clause of show_type/1
Warning: 	/home/jan/ale.swi.pl:6173:10: 1-st clause of show_type/1
Warning: ct/7, which is referenced by
Warning: 	/home/jan/ale.swi.pl:1832:2: 2-nd clause of map_cons/7
Warning: edge/8, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2715:30: 1-st clause of count_edges/1
Warning: empty/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:7487:2: 15-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:3632:4: 12-th clause of if_h/2
Warning: empty_cat/7, which is referenced by
Warning: 	/home/jan/ale.swi.pl:6599:5: 1-st clause of edge/1
Warning: 	/home/jan/ale.swi.pl:6554:2: 1-st clause of empty/0
Warning: 	/home/jan/ale.swi.pl:2727:2: 1-st clause of get_edge/9
Warning: 	/home/jan/ale.swi.pl:3250:8: 1-st clause of nth_index/10
Warning: ext/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5339:6: 1-st clause of compile_ext/2
Warning: 	/home/jan/ale.swi.pl:5341:5: 1-st clause of compile_ext/2
Warning: 	/home/jan/ale.swi.pl:5198:2: 3-th clause of maximal_defaults/0
Warning: ext_sub_type/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5377:3: 2-nd clause of compile_ext_sub_assert_type/6
Warning: extensional/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5354:13: 1-st clause of compile_ext_sub_assert/0
Warning: 	/home/jan/ale.swi.pl:2415:4: 5-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:2357:2: 8-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:2507:6: 9-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:2510:2: 10-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:1667:13: 2-nd clause of prune/2
Warning: 	/home/jan/ale.swi.pl:1676:10: 2-nd clause of prune/2
Warning: featval/6, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2160:5: 7-th clause of add_to/5
Warning: 	/home/jan/ale.swi.pl:2241:5: 2-nd clause of pathval/7
Warning: fsolve/5, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2199:2: 12-th clause of add_to/5
Warning: fun/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2197:2: 12-th clause of add_to/5
Warning: 	/home/jan/ale.swi.pl:4459:2: 12-th clause of compile_desc/12
Warning: 	/home/jan/ale.swi.pl:4563:2: 12-th clause of compile_desc/13
Warning: generate/6, which is referenced by
Warning: 	/home/jan/ale.swi.pl:7404:2: 1-st clause of gen/4
Warning: 	/home/jan/ale.swi.pl:7446:2: 2-nd clause of generate_list/6
Warning: if/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5935:15: 1-st clause of compile_dcs/2
Warning: 	/home/jan/ale.swi.pl:5905:44: 1-st clause of compile_generate/2
Warning: 	/home/jan/ale.swi.pl:5433:3: 1-st clause of find_xeq/2
Warning: 	/home/jan/ale.swi.pl:6753:4: 1-st clause of show_clause2/1
Warning: intro/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5277:10: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5280:13: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5284:14: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5288:8: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5289:25: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5293:16: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5550:7: 1-st clause of compile_featval/2
Warning: 	/home/jan/ale.swi.pl:5565:29: 1-st clause of compile_featval4/2
Warning: 	/home/jan/ale.swi.pl:5156:15: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5162:18: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:1504:23: 1-st clause of feature/1
Warning: 	/home/jan/ale.swi.pl:1547:5: 2-nd clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:5184:2: 2-nd clause of maximal_defaults/0
Warning: 	/home/jan/ale.swi.pl:1517:2: 1-st clause of restricts/3
Warning: iso_sub_seq/3, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2353:8: 2-nd clause of iso_seq/1
Warning: lex/4, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2645:18: 1-st clause of build/3
Warning: 	/home/jan/ale.swi.pl:2646:4: 1-st clause of build/3
Warning: 	/home/jan/ale.swi.pl:5750:25: 1-st clause of export_words/2
Warning: 	/home/jan/ale.swi.pl:6303:2: 1-st clause of lex/1
Warning: 	/home/jan/ale.swi.pl:5725:2: 1-st clause of retract_lex_one/1
Warning: lex_rule/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5660:12: 1-st clause of compile_lex_rules/2
Warning: 	/home/jan/ale.swi.pl:5661:12: 1-st clause of compile_lex_rules/2
Warning: 	/home/jan/ale.swi.pl:7678:5: 2-nd clause of gen_lex_close/8
Warning: 	/home/jan/ale.swi.pl:7680:5: 2-nd clause of gen_lex_close/8
Warning: 	/home/jan/ale.swi.pl:1999:5: 4-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:2001:5: 4-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:6686:6: 1-st clause of lexrule2/1
Warning: 	/home/jan/ale.swi.pl:6687:6: 1-st clause of lexrule2/1
Warning: lex_rule/8, which is referenced by
Warning: 	/home/jan/ale.swi.pl:3614:2: 2-nd clause of lex_close/10
Warning: macro/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2179:6: 10-th clause of add_to/5
Warning: 	/home/jan/ale.swi.pl:4450:20: 10-th clause of compile_desc/12
Warning: 	/home/jan/ale.swi.pl:4451:3: 10-th clause of compile_desc/12
Warning: 	/home/jan/ale.swi.pl:4553:20: 10-th clause of compile_desc/13
Warning: 	/home/jan/ale.swi.pl:4554:3: 10-th clause of compile_desc/13
Warning: 	/home/jan/ale.swi.pl:6527:4: 1-st clause of macro/1
Warning: mgsc/7, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2277:10: 4-th clause of add_to_typeact/8
Warning: 	/home/jan/ale.swi.pl:5503:2: 2-nd clause of map_mgsat_act/6
Warning: 	/home/jan/ale.swi.pl:1960:1: 2-nd clause of map_new_feats_find/11
Warning: 	/home/jan/ale.swi.pl:1977:1: 2-nd clause of map_new_feats_introduced/6
Warning: 	/home/jan/ale.swi.pl:1769:22: 4-th clause of uact/10
Warning: parsing/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:6660:2: 1-st clause of write_out/2
Warning: rule/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:3692:9: 1-st clause of close_emptys/3
Warning: 	/home/jan/ale.swi.pl:5840:17: 1-st clause of compile_rules/2
Warning: 	/home/jan/ale.swi.pl:5846:17: 1-st clause of compile_rules/2
Warning: 	/home/jan/ale.swi.pl:5850:17: 1-st clause of compile_rules/2
Warning: 	/home/jan/ale.swi.pl:5864:15: 1-st clause of compile_rules/2
Warning: 	/home/jan/ale.swi.pl:5870:15: 1-st clause of compile_rules/2
Warning: 	/home/jan/ale.swi.pl:7518:3: 17-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:7552:3: 19-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:7653:3: 21-th clause of if_b/2
Warning: 	/home/jan/ale.swi.pl:3626:9: 11-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:6772:4: 1-st clause of rule/1
Warning: rule/7, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2698:8: 1-st clause of add_edge/8
Warning: 	/home/jan/ale.swi.pl:2702:11: 1-st clause of add_edge/8
Warning: 	/home/jan/ale.swi.pl:2689:8: 1-st clause of add_edge_deref/8
Warning: 	/home/jan/ale.swi.pl:2693:11: 1-st clause of add_edge_deref/8
Warning: semantics/1, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5903:4: 1-st clause of compile_generate/2
Warning: 	/home/jan/ale.swi.pl:7421:2: 15-th clause of if_h/2
Warning: sub/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:5224:3: 1-st clause of bottom_defaults/0
Warning: 	/home/jan/ale.swi.pl:5276:10: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5279:13: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5282:14: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5287:8: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5292:16: 1-st clause of compile_approp/2
Warning: 	/home/jan/ale.swi.pl:5549:6: 1-st clause of compile_featval/2
Warning: 	/home/jan/ale.swi.pl:5127:14: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5132:18: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5137:32: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5140:15: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5148:15: 1-st clause of compile_sub_type/2
Warning: 	/home/jan/ale.swi.pl:5172:2: 1-st clause of maximal_defaults/0
Warning: 	/home/jan/ale.swi.pl:1351:7: 1-st clause of subs/2
Warning: 	/home/jan/ale.swi.pl:1355:9: 1-st clause of subs/2
Warning: sub_type/2, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2272:7: 4-th clause of add_to_typeact/8
Warning: 	/home/jan/ale.swi.pl:2300:12: 1-st clause of add_to_typecons/7
Warning: 	/home/jan/ale.swi.pl:2301:14: 1-st clause of add_to_typecons/7
Warning: 	/home/jan/ale.swi.pl:5349:5: 3-th clause of compile_ext_act/3
Warning: 	/home/jan/ale.swi.pl:5354:28: 1-st clause of compile_ext_sub_assert/0
Warning: 	/home/jan/ale.swi.pl:7444:2: 2-nd clause of generate_list/6
Warning: 	/home/jan/ale.swi.pl:1427:18: 4-th clause of if_h/1
Warning: 	/home/jan/ale.swi.pl:1428:18: 4-th clause of if_h/1
Warning: 	/home/jan/ale.swi.pl:1538:28: 8-th clause of if_h/1
Warning: 	/home/jan/ale.swi.pl:1457:2: 2-nd clause of insert_if_minimal/3
Warning: 	/home/jan/ale.swi.pl:1459:2: 3-th clause of insert_if_minimal/3
Warning: 	/home/jan/ale.swi.pl:1947:4: 1-st clause of map_new_feats_find/11
Warning: 	/home/jan/ale.swi.pl:3852:3: 5-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3861:6: 5-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3865:9: 5-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3873:6: 5-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3887:3: 6-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3894:6: 6-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3898:9: 6-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3909:6: 6-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3926:3: 7-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3930:6: 7-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3948:3: 8-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:3952:6: 8-th clause of match_cat_to_next_cat/9
Warning: 	/home/jan/ale.swi.pl:2541:2: 1-st clause of match_list/12
Warning: 	/home/jan/ale.swi.pl:2565:2: 2-nd clause of match_list_rest/9
Warning: 	/home/jan/ale.swi.pl:4017:3: 5-th clause of match_to_next_cat/8
Warning: 	/home/jan/ale.swi.pl:4020:6: 5-th clause of match_to_next_cat/8
Warning: 	/home/jan/ale.swi.pl:4033:3: 6-th clause of match_to_next_cat/8
Warning: 	/home/jan/ale.swi.pl:4036:6: 6-th clause of match_to_next_cat/8
Warning: 	/home/jan/ale.swi.pl:5507:11: 1-st clause of mgsat_cons/7
Warning: 	/home/jan/ale.swi.pl:6161:16: 1-st clause of show_type/1
Warning: 	/home/jan/ale.swi.pl:6163:20: 1-st clause of show_type/1
Warning: 	/home/jan/ale.swi.pl:6165:20: 1-st clause of show_type/1
Warning: 	/home/jan/ale.swi.pl:2908:2: 2-nd clause of subsume_type_act/18
Warning: 	/home/jan/ale.swi.pl:2923:2: 3-th clause of subsume_type_act/18
Warning: 	/home/jan/ale.swi.pl:1791:12: 1-st clause of ucons/8
Warning: 	/home/jan/ale.swi.pl:1792:14: 1-st clause of ucons/8
Warning: 	/home/jan/ale.swi.pl:1793:14: 1-st clause of ucons/8
Warning: subsume_type/13, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2806:10: 2-nd clause of subsume/9
Warning: 	/home/jan/ale.swi.pl:2814:10: 2-nd clause of subsume/9
Warning: 	/home/jan/ale.swi.pl:2817:7: 2-nd clause of subsume/9
Warning: u/6, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2118:6: 2-nd clause of add_to/5
Warning: 	/home/jan/ale.swi.pl:2135:5: 5-th clause of add_to/5
Warning: 	/home/jan/ale.swi.pl:1580:22: 1-st clause of ud/4
Warning: 	/home/jan/ale.swi.pl:1591:28: 1-st clause of ud/5
Warning: 	/home/jan/ale.swi.pl:1602:28: 1-st clause of ud/6
Warning: 	/home/jan/ale.swi.pl:2970:2: 1-st clause of unify_disjunct_image/9
Warning: unify_type/3, which is referenced by
Warning: 	/home/jan/ale.swi.pl:2499:17: 2-nd clause of check_inequal_conjunct/3
Warning: 	/home/jan/ale.swi.pl:1742:2: 3-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:2258:2: 5-th clause of if_h/2
Warning: 	/home/jan/ale.swi.pl:1898:2: 1-st clause of map_feats_unif_act/15
Warning: 	/home/jan/ale.swi.pl:1480:2: 2-nd clause of unify_types/3
true.

I just committed a new Logtalk lint check for redefined standard operators. with this ale.swi.pl file I now get:

?- logtalk_compile('ale.swi.pl').
*     Redefining standard operator op(200,fy,@) as op(375,fx,@)
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 1308
*     
*     Redefining standard operator op(700,xfx,=\=) as op(775,fx,=\=)
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 1311
*     
*     Redefining standard operator op(600,xfy,:) as op(800,xfy,:)
*       while compiling object ale
*       in file /Users/pmoura/Desktop/ale.swi.pl at or above line 1312
...

In the past, while porting and working with Prolog legacy code, I had a fair share of redefined standard operators resulting in bugs not always easy to diagnose and find. Sometimes we get a syntax error but most of the times is just failures somewhere. E.g. a clause no longer being used as head arguments no longer unify.

This new lint check is already in the git version and it will be on 3.35.0, expected in earlier February.

2 Likes

I’m having a look at ALE. I now have a version that runs again, based on the SICStus code and using conditional compilation (:- if) to work around a few incompatibilities. The problem is rather interesting.

ALE is a DSL (Domain Specific Language) that is implemented as follows:

  • Introduce a lot of operators to make the syntax valid Prolog
  • Consult this file as a Prolog file, so we have a bunch of Prolog terms in the DB.
  • Derive a compiled representation from these ALE terms.

So far, so good. The curious part is the last step. That contains of a number of compilation stages that depend on the output (compiled clauses) of previous stages. In SICStus they do this using the following cute trick

  • Touch an empty file .alec_throw.
  • Assert alec(Stage) to indicate the next stage to execute.
  • compile(’.alec_throw’), where the compilation uses term_expansion/2 on end_of_file to derive the clauses for that stage and get them compiled.

This works in SICStus as consult/1 and compile/1 do not touch previously loaded code from that file. SWI-Prolog’s consult always wipe what has been loaded before, so this doesn’t work. So, for SWI-Prolog they derived a really clever trick :slight_smile:

  • Create the .alec_throw file

  • Assert in alec(Stage) all the stages.

  • Expand end_of_file, and now comes the clever part: end_of_file is expanded into a list like this:

    [clause1, clause2, ... (:- alec_catch(Code))|Code]
    

    That was mind blowing :slight_smile: The old SWI-Prolog 5.6 term expansion would process the clauses and at the end call alect_catch/1 to extend the list with the next stage, and-so-forth. The last alec_catch/1 call binds its list to [end_of_file], ending the process.

Unfortunately that doesn’t work anymore as the expansion list is passed on to further expansion units and type checked to be a proper list. I had a half-way plan to see whether I could turn the above into a supported feature, but that became really messy.

My revival of ALE now uses assertz/1, followed by compile_predicates/1 at the end of the translation process. The main disadvantage thereof is that it breaks the source administration, i.e., the generated predicates are not known to come from the original grammar file.

I have contacted Gerald Penn to see how to make the new version available. I wonder how much use there still is for this code. It is old, but there are surely still relevant ideas there.

If you are reading The ALE Homepage

you might need the correct links for

Head-Driven Phrase Structure Grammar (HPSG)

Lexical-Functional Grammar (LFG).

1 Like