[mercury-users] converting char* to terms

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Sep 15 06:13:46 AEST 1998


On 14-Sep-1998, ingenuit <at at ingenuity-sw.com> wrote:
> I have a similar problem:  perhaps you can suggest an answer:
> 
> How to use a c_code returned char* as a term?

Do you mean as a value of type `term__term',
or as a value of some other type?

> With help from the mailing list, I have linked in a C function
> which returns a char* to a (possibly long) string.  The string
> is guaranteed to be a correctly formed Mercury term.  
> 
> (If I write this
> string to a file then io__read will successfully read a ground term.)
> 
> The compiler desperately wants this char* to be a string.  
> It *is* a compound term with functor and args.  
> 
> 1) Is there any way to directly to get Mercury to use a 
> "C" return of char* as a term and not a string?

No.

> 2) Is there any way to make Mercury use a string as a buffered stream
> so that preds that read from a stream can be used on the string,
> instead? 

No, not yet.

In the latest development release there is term__read_term_from_string,

> 3) What is the upper size limit on a Mercury string, if any?

There's no limit (except that even virtual memory is finite).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the users mailing list