Re: Singleton variable in branch
FERNANDO SAENZ PEREZ <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAMDa7mt6w8uO47QtfgFqY_TYxWUKpeACkdaTMz6FXM4vOiyM9w@mail.gmail.com> |
Thanks! 2013/12/16 Paulo Moura <[email protected]> > > On 16/12/2013, at 15:58, FERNANDO SAENZ PEREZ <[email protected]> wrote: > > > Hello, > > Given the following system session in SWI-Prolog 6.6.1 (Windows, stable > > version): > > > > %%%%%%%%%%%%%%%%%%%%%% > > > > Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 6.6.1) > > Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam > > SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, > > and you are welcome to redistribute it under certain conditions. > > Please visit http://www.swi-prolog.org for details. > > > > For help, use ?- help(Topic). or ?- apropos(Word). > > > > 1 ?- [p]. > > Warning: c:/fernan/research/bddeduc/des/des3.3.3/p.dl:1: > > Singleton variable in branch: B > > % p.dl compiled 0.00 sec, 2 clauses > > true. > > > > 2 ?- listing. > > > > :- thread_local thread_message_hook/3. > > :- dynamic thread_message_hook/3. > > :- volatile thread_message_hook/3. > > > > > > p(A) :- > > ( functor(A, _, B) > > -> ( foo(B) > > -> foo(B) > > ; foo(B) > > ) > > ; foo(B) > > ). > > true. > > > > %%%%%%%%%%%%%%%%%%%%%% > > > > I do not understand the warning. I think that B is used in all branches, > > isn't it? > > That's not the issue. If functor/3 fails, B is a singleton variable. If > you take into account a failure of functor/3, your code becomes equivalent > to: > > p(A) :- > ( fail > ; foo(B) > ). > > > In addition, it is said that 2 clauses have been compiled. Is it so? The > > source file includes the very same clause as listed. > > My only explanation involves parallel universes :-) But maybe Jan can shed > some light here. > > Cheers, > > Paulo > > ----------------------------------------------------------------- > Paulo Moura > Logtalk developer > > Email: <mailto:[email protected]> > Web: <http://logtalk.org/> > ----------------------------------------------------------------- > > > > > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > -------------- next part -------------- HTML attachment scrubbed and removed