Re: is/2 (was: Re: CLP(FD): what is necessary?)



On Thu, 13 Mar 2008 21:24:17 +0000, Jan Wielemaker wrote:

On 2008-03-13, bart demoen <bmd@xxxxxxxxxxxxxx> wrote:
Source level variables to the right of is/2 (or in < =:= ...)
should be numbers, and not be evaluated.

I've seen that argument before.

It is not an argument - it is a position statement.

I even got some idea why when we
discussed the fac/2 function a while ago.

I don't see the relation with the discussion about fac/2, but maybe you
can clarify it.

I'm still not terribly convinced though.

I will settle for you being mildly convinced :-)

The obvious downside is you need a new name and more
explanation in books and manuals. What do you gain?

TYPES

Not a lot of performance.

True - performance is not my reason.

The implementation can still eagerly hope for
numbers and optimise for that as it covers 99% of the cases. It must
always be prepared to deal with something else. It can decide between an
error or calling an evaluator and continue. What is the advantage of the
error?

Simplicity of implementation - putting some of your implementation effort
in a place where it pays off much more - types - avoiding bad expectations
(ah, I remember, this is the fac/2 thing of course !)


Point students that the above is a bad idea? Not really convincing.

Of course that is not convincing - I wouldn't use that argument at all.
TYPES and the fact that Prolog is (AFAIK) unique in this particular
language design mistake.


Prolog could also have the ability to evaluate source level variables,
but it should be a separate built-in - and if Prolog would have only
one predicate, it should be the one that does not evaluate source level
vars.

... and have everyone write his/her own evaluator?

Of course not - you can put it easily in a library.


I've used evaluation
of variables quite a few times. I cannot recall a case where an error
would have helped in any way.

Surely, if a feature exists, it will be used and replacing it by an error
would render your use futile. But that doesn't mean it is a good language
feature. I sometimes use my screwdriver as a hammer - it doesn't make me a
better carpenter !

Cheers

Bart Demoen
.