Subject: Re: [SWIPL] Help w/module loading

From: Jan Wielemaker <[email-masked]>
Date: Wed, 26 Sep 2001 16:42:22 +0200

On Mon, 13 Aug 2001, scritch mephisto wrote:
>Howdy,
>
>Brand new to Prolog, I need a little hand holding.  Basically, I
>need the modulus operator (mod).  Can someone explain the following
>interaction?
>
>First of all, here is my .plrc (note, autloading is on and verbose).
>:- set_prolog_flag(autoload, true).
>:- set_prolog_flag(verbose_autoload, true).
>
>And, here is some interactive Prolog:
>?- help(mod).
>%  library(helpidx) compiled into help_index 0.13 sec, 125,484 bytes
>% /usr/lib/swi-prolog/library/help compiled into online_help
>0.14 sec, 138,868 bytes
>% /usr/lib/swi-prolog/library/backcomp compiled into backward_compatibility
>0.00 sec, 3,812 bytes
>% /usr/lib/swi-prolog/library/quintus compiled into quintus
>0.02 sec, 11,772 bytes
>+IntExpr1 mod +IntExpr2
>[snipped]
>Yes
>
>
>?- 5 mod 2.
>ERROR: Undefined procedure: mod/2

mod/2 is a *function*, not a *predicate*, so it only
means anything as argument to is/2, =:=/2, </2, etc.

Built-in functions are not subject to the module system.

>?- 2 = 17 mod 5.

Simply tries to *unify* 2 with mod(17,5), which clearly fails.

>?- 2 is 17 mod 5.
>Yes

is/2 *evaluates* 17 mod 5, yielding 2, which unifies with 2,
so the answer is `yes'.

>But then why does this similar example not work:
>min(10, X).

What is this supposed to do?  min is a function taking the
minimum of its arguments, making X is min(2,3) yield X=2.

	--- Jan