[mercury-users] string_stream impl, re: redirecting output to streams
Ian MacLarty
maclarty at cs.mu.OZ.AU
Fri Feb 17 06:16:52 AEDT 2006
Sorry for sending this twice. I didn't come through for a long time,
so I sent it again thinking it got lost.
On 16 Feb 2006, at 19:57, Ian MacLarty wrote:
> On 16 Feb 2006, at 03:55, Ralph Becket wrote:
>
>> Ian MacLarty, Wednesday, 15 February 2006:
>>> Not in principle, but I think you might have problems with the C code
>>> that ultimately does things with the strings (for example instead of
>>> passing the string to printf to write it out, you'd have to have
>>> extra
>>> code to handle nulls in the string which might be an efficiency
>>> problem).
>>
>> Many functions in the string library are O(n) rather than O(1) because
>> they always do string bounds checking. It would be better to define
>>
>> typedef struct { MR_Integer length; const char chars[] } MR_String;
>>
>> and then pass MyStr->chars to C rather than just MyStr.
>>
>> I think this would be a Good Change to make.
>>
>
> One question: How do you propose to handle nulls in the writing out
> of strings? I mean suppose I build up a string and there is a null in
> there somewhere and then I write out the string. Should the string
> only be written out to the null, even though it's length is greater
> than the position of the null? Certainly for binary strings you'd
> want to print the whole thing out, even the characters past the null.
> This will require you to use something else besides printf. Perhaps
> there should be different predicates for writing out all the
> characters in a string and for writing out only the characters up till
> the first null, but then why not have two types?
>
> Ian.
>
> -----------------------------------------------------------------------
> ---
> mercury-users mailing list
> post: mercury-users at cs.mu.oz.au
> administrative address: owner-mercury-users at cs.mu.oz.au
> unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message:
> unsubscribe
> subscribe: Address: mercury-users-request at cs.mu.oz.au Message:
> subscribe
> -----------------------------------------------------------------------
> ---
>
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list