[PPL-devel] Bignums and the foreign language interface
Roberto Bagnara
bagnara at cs.unipr.it
Wed Dec 25 21:07:19 CET 2002
Hi there,
how can bignums be communicated to/from Ciao Prolog?
More precisely, since we have
$ ciao
Ciao-Prolog 1.9 #34: Sat Nov 30 19:17:43 CET 2002
?- current_prolog_flag(bounded, X).
X = false ?
yes
?-
integers are unbounded. However, the function
ciao_term ciao_integer(int i)
allows to build only integers that fit in a machine
word. The problem with the design of the function
int ciao_to_integer(ciao_term term)
appears to be more serious, as the C application seems
to have no way of detecting whether the conversion was
successful or not.
It would seem better to define something like
int ciao_to_integer(ciao_term term, long* pl)
so that 0 is returned if the conversion failed (in which
case *pl has not been touched), and a number different from 0
otherwise. Bignums could then be communicated with a pair
of functions ciao_get_number_chars() and ciao_put_number_chars().
What do you think?
Best wishes to you all
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the PPL-devel
mailing list