Jan Wielemaker | 5 Oct 17:37
Favicon

Re: 5.7.X : problem with attributed variables and memberchk ?

On Sunday 05 October 2008 17:14:47 Bart Demoen wrote:
> > "_ = something" is simply replaced by `true'.
> > I'm still considering GCC-like warnings here, such as
> >
> >     'Goal has no effect'
> >     'Goal always fails'
>
> I had the message "Stupid unification" in the BIM-Prolog compiler long
> ago. Just before shipping it to customers, someone would replace it
> with something more gentle because it upset the customers :-)

The SWI-Prolog customers don't pay, but still I prefer to be a bit more
polite :-)

> I think that flagging such code is a really nice thing, because it
> almost always is due to typos.
>
> Don't stop there though - flag first occurrences of variables in
> arithmetic expressions, uses of functor/3 with a non-integer in third
> argument, ..., and look (at compile time) inside what is asserted,
> meta-called, etc.

The interesting question of course is, what is better left to a type
checker and what is better done by the compiler? Your functor/3 example
appears to be as a clear example of an issue for the type checker.

Of course, "_ = something" is not a type error, so at least strickly
speaking it isn't the domain of the type checker. It could still be
argued it must be the responsibility of some sort of static analysis
tool outside the compiler proper. On the other hand, the compiler does a
lot of the work, so it can do some of these tasks without any overhead.
In the Var = Something example it already distinguishes singleton, first
use and non-first use, so while writing the compiler you have to do
*something* if you see <singleton> = something ...

	Cheers --- Jan

_______________________________________________
SWI-Prolog mailing list
SWI-Prolog <at> iai.uni-bonn.de
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog


Gmane