[PPL-devel] Re: Bignums and the foreign language interface

Manuel Carro mcarro at fi.upm.es
Tue Jan 7 20:59:10 CET 2003


Roberto Bagnara writes:

>> Are these in addition to the old, unchecked
>> 
>>    ciao_term ciao_integer(int i)
>> ?
>> If so, I believe `ciao_to_integer_check(ciao_term term, int *res)'
>> is redundant.  I mean:

    Yes, it is redundant.  It is there only for convenience.  It is
defined as

ciao_bool ciao_to_integer_check(ciao_term term, int *res) {
  if (ciao_fits_in_int(term)) {
    *res = ciao_to_integer(term);
    return TRUE;
  } else return FALSE;
}

    I kept it only for the brevity of writing

if (!ciao_to_integer_check(term, &res)){
    do_something_special_here()
}

in a C library-like style.
    

>> Another curiosity is: why `int' instead of `long' (the widest,
>> standard integral type)?

    Good question.  No special reason, in fact: it probably should
have been 'long' since the beginning --- most likely we will change
it.  In fact, the size of long is the same as an int's right now in
Intel machines and gcc.  Actually, the widest standard data type now
is the ISO C99 long long int, guaranteed to be at least 64 bits.


>> If, as I suppose, the char* obtained with
>> `ciao_get_number_chars(ciao_term term)' is under the responsibility
>> of the Prolog engine, its lifetime should be documented.

    No, it is not: its management is passed on to the C side.  The
documentation reads:

@item @tt{char *ciao_get_number_chars(ciao_term term);}

It converts @tt{ciao_term} (which must be instantiated to a number)
into a C string representing the number in the current radix.  The
string returned is a copy, to be explicitly deallocated by the user C
code.

>> If this is not too much, I would prefer obtaining a development snapshot
>> of Ciao.  I still have problems with the foreign language interface
>> and I hope they are caused by bugs you have already fixed ;-)

    No problem at all. 

    Cheers,

        MCL

_______________________________________________________________________
Internal error: Memory corruption [the program was trying to bribe gdb]



More information about the PPL-devel mailing list