
Hi there,
I believe the following behavior of the CVS version of YAP witnesses a bug (or, quite possible, a misunderstanding on my part):
$ yap [ Restoring file /usr/local/lib/Yap/startup ] [ YAP version Yap-4.3.23 ] ?- current_prolog_flag(bounded,X).
X = false ? ?- X is 333333333333333, integer(X).
no ?- X is 33333333, integer(X).
X = 33333333 ? ?- X is 333333333333333, float(X).
no ?- X is 333333333333333, number_chars(X,L).
X = 333333333333333, L = [51,51,51,51,51,51,51,51,51,51,51,51,51,51,51] ?
In words, the Prolog engine first declares it is employing unbounded integers, then it silently converts an integer numeral to... to what? Is this a bug? Am I missing something? All the best
Roberto

Hi Roberto,
It is a bug, definitely.
Cheers,
Vitor

Vitor Santos Costa wrote:
It is a bug, definitely.
Dear Vitor,
I have tried the CVS version of YAP to see whether you fixed the bug about bignums (you did, thanks!) and I have noticed a problem in that version. This is witnessed by the attached program: if you try the query "?- bug." you will see that something wrong is printed. Cheers
Roberto

Dear Roberto,
That was the new unified scanner. Hopefully, in the end it should be more stable.
Cheers,
Vitor

Dear Vitor,
we now need to communicate bignums to and from the C interface. I didn't find provision for this in the current interface. What is needed is
1) a predicate to test whether a YAP integer would fit into a long int so that IntOfTerm() can be used;
2) a sort of NumberCharsOfTerm() to get a char* containing the number chars corresponding to a (possibly big) YAP integer;
3) a sort of MkIntFromNumberChars to create a YAP integer out of a char* containing number chars.
It would be nice to have these or other equivalent facilities in YAP. What do you think? All the best,
Roberto

Hi Roberto
Sorry for the long delay in answering, been a bit busy with another visit to Wisconsin.
we now need to communicate bignums to and from the C interface. I didn't find provision for this in the current interface. What is needed is
I changed the interface to support bignums. Please check the CVS (and please do report any bugs).
- a predicate to test whether a YAP integer would fit into a long int so that IntOfTerm() can be used;
The interface I wrote now separates integers from bignums, so you should just use YAP_IsIntTerm vs YAP_IsBigNumTerm. Is that ok for you?
- a sort of NumberCharsOfTerm() to get a char* containing the number chars corresponding to a (possibly big) YAP integer;
You mean like writing a term to a string? I suppose it does make sense now that I have YAP_ReadBuffer to also have YAP_WriteBuffer. I'll include that next. Right now, you'd have to use YAP_BigIntFromTerm and then use the GMP routine to send it out on a string.
- a sort of MkIntFromNumberChars to create a YAP integer out of a char* containing number chars.
The interface now has YAP_ReadBuffer which will do that.
It would be nice to have these or other equivalent facilities in YAP. What do you think?
I do agree, sorry for the delay!
Cheers,
Vitor
PS: Ricardo, you may want to consider including this functionality in 4.4.
participants (2)
-
Roberto Bagnara
-
Vitor Santos Costa