Re: Ann: SWI-Prolog 6.5.1

Abramo Bagnara <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Organization Opera Unica
Message-ID <[email protected]>
Il 13/08/2013 10:29, Abramo Bagnara ha scritto:
> Il 12/08/2013 22:43, Jan Wielemaker ha scritto:
>> Hi,
>>
>> I've uploaded SWI-Prolog 6.5.1.  There are a lot of changes.  Highlights:
>>
>>   - Detection of `semantic singletons' by the compiler.  This proofs
>>     to result in a quite high percentage of real bugs.  My rough
>>     estimate is about 1/3th!  And this is on established code!
> 
> The added warnings are indeed wonderful and *very* useful to spot bugs.
> 
> Still I have some problems to write warning free code in presence of
> term expansion and conditional term expansion:
> 
> %flag :- fail.
> flag.
> 
> :- if(flag).
> term_expansion((:- f(A)), f(A, A)).
> :- else.
> term_expansion((:- f(_A)), []).
> :- endif.
> 
> :- f(A).
> :- f(_A).
> 
> Warning: /home/abramo/z.pl:10:
> 	Singleton variables: [A]
> Warning: /home/abramo/z.pl:11:
> 	Singleton-marked variable appears more than once: _A
> 
> Do I have a way to write :- f(A) (so to have warning from the expansion
> with singleton variables when flag is true) and to avoid warning when
> flag is false?
> 
> The other way is to write :- f(_A) and to use style_check inside the
> expansion, but in this case I'd lose the warning from the expansion.
> 

A similar issue comes from the following:

goal_expansion(nofail(G),
               (G *->
                   true
               ;
                   print_message(error, assumption_failed(G)),
                   trace,
                   G
               )).

f1(In) :-
    nofail(p(In, _Out)).

f2(In) :-
    nofail(p(In, Out)).

f3(In) :-
    nofail(p(In, _)).


Both f1 and f2 gives warnings, f3 does not give any warnings, but asks
to me to reduce code readability.


-- 
Abramo Bagnara

Via Borghesi, 16
48014 Castel Bolognese (RA) - Italy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.