Re: arithmetic_function (SWI)
- From: "Mauro Di Nuzzo" <picorna@xxxxxxxxx>
- Date: Thu, 9 Mar 2006 15:10:34 +0100
Just two more issue regarding arithmetic function handling in SWI Prolog.
In particular, I got the following segmentation fault errors, that I think
one might avoid to see.
?- arithmetic_function(c/0).
yes
?- X is c. % *see later
?- arithmetic_function(c/0).
yes
?- assert(( c(_) :- throw(error(instantiation_error, _)) )). % or some other
exception
yes
?- X is c. % *see later
Both goal* return this (I marked them with an asterisk):
ERROR: is/2: Undefined procedure: c/1
ERROR: is/2: Caught signal 11 (segv)
I do not know, but they seem bugs. Arent they?
Thanks again.
M
"Mauro Di Nuzzo" <picorna@xxxxxxxxx> ha scritto nel messaggio
news:yzVPf.64$8g7.61@xxxxxxxxxxxxxxxxxxxxxx
Thank you very much Jan.in
Having understood what you said me, I tried to put an arithmetic function
a module by this way:way
--------
% name.pl
:- module(some, []). % I can export here the function c/0 in the same
I export, for example, an operator.associated
:- arithmetic_function(c/0).
c(10).
% eof
--------
?- consult('name.pl').
yes
?- X is c.
ERROR: is/2: Arithmetic: 'c/0' is not a function
So I am unable to use c/0 from the toplevel (or just from a module other
than 'some').
What I want is to have the arithmetic function c/0 imported into context
module, and not the predicate c/1.
Does a method to achieve this exist, since module export declaration does
not include arithmetic functions?
:)
M
"Jan Wielemaker" <jan@xxxxxxxxxxxxxxxxxxx> ha scritto nel messaggio
news:slrne105s3.4b0.jan@xxxxxxxxx
On 2006-03-09, Mauro Di Nuzzo <picorna@xxxxxxxxx> wrote:Prolog.
Hi All.
This is an issue regarding arithmetic_function/1 predicate under SWI
this
Suppose I define a new arithmetic function, namely a constant c/0, in
it isway
:- 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
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
predicates (with arity + 1) are, let's say, invisible?
You can't. You can put them in a module though.
--- Jan
.
- Follow-Ups:
- Re: arithmetic_function (SWI)
- From: Jan Wielemaker
- Re: arithmetic_function (SWI)
- References:
- arithmetic_function (SWI)
- From: Mauro Di Nuzzo
- Re: arithmetic_function (SWI)
- From: Jan Wielemaker
- Re: arithmetic_function (SWI)
- From: Mauro Di Nuzzo
- arithmetic_function (SWI)
- Prev by Date: Re: arithmetic_function (SWI)
- Next by Date: Re: arithmetic_function (SWI)
- Previous by thread: Re: arithmetic_function (SWI)
- Next by thread: Re: arithmetic_function (SWI)
- Index(es):
Relevant Pages
|
|