Re: arithmetic_function (SWI)



On 2006-03-09, Mauro Di Nuzzo <picorna@xxxxxxxxx> wrote:
Hi All.
This is an issue regarding arithmetic_function/1 predicate under SWI Prolog.

Suppose I define a new arithmetic function, namely a constant c/0, in this
way

:- arithmetic_function(c/0).
c(10).

Consider no changes in the context module when I consult it from the
toplevel.
Then I try:

?- X is c*2.
X = 20

That's ok. But I should have written:

?- c(Y).
Y = 10

So I can really access the predicate c/1. Instead, for SWI builtin
arithmetic function, this is not the case.
In fact, this happens:

?- Z is e.
Z = 2.71828

?- e(E).
ERROR: undefined procedure: e/1

So it seems that predicate e/1 associated with arithmetic function e/0 it is
asserted elseWHERE.
Finally, my question, WHERE?

Nowhere. All built-in arithmetic functions are connected to C-functions
using some internal interface (see pl-arith.c). One of these exploits a
call-back to Prolog to make predicates available as functions.

In other words, how can I handle arithmetic functions so that associated
predicates (with arity + 1) are, let's say, invisible?

You can't. You can put them in a module though.

--- Jan
.



Relevant Pages

  • arithmetic_function (SWI)
    ... This is an issue regarding arithmetic_function/1 predicate under SWI Prolog. ... Suppose I define a new arithmetic function, namely a constant c/0, in this ... So it seems that predicate e/1 associated with arithmetic function e/0 it is ...
    (comp.lang.prolog)
  • Re: arithmetic_function (SWI)
    ... So I am unable to use c/0 from the toplevel (or just from a module other ... What I want is to have the arithmetic function c/0 imported into context ... This is an issue regarding arithmetic_function/1 predicate under SWI ... So it seems that predicate e/1 associated with arithmetic function e/0 ...
    (comp.lang.prolog)
  • Re: arithmetic_function (SWI)
    ... Just two more issue regarding arithmetic function handling in SWI Prolog. ... This is an issue regarding arithmetic_function/1 predicate under SWI ...
    (comp.lang.prolog)
  • Re: arithmetic_function (SWI)
    ... What I want is to have the arithmetic function c/0 imported into context ... Does a method to achieve this exist, since module export declaration does ... Declaring a function f/n simply means you also have the predicate ... The proper way around might be to allow exporting functions ...
    (comp.lang.prolog)
  • Re: Could not load foreign predicates in SWI Prolog 5.6.
    ... > foregin predicate (in C language) and use it in SWI Prolog. ... > into the prolog interpreter, ...
    (comp.lang.prolog)