On Tue, Jul 22, 2014 at 6:46 AM, [email protected] <[email protected]>
wrote:

> A case for ternary computing is not really a bad idea ;)
>
> On 21-7-2014 21:42, Hans-Peter Diettrich wrote:
>
>> Dmitry Boyarintsev schrieb:
>>
>>  How about introducing a default parameter?
>>> The parameter keeps the method backward compatible, allowing write a
>>> string without the prefix.
>>>
>>> public procedure TStream.WriteAnsiString(
>>>   const S: string;
>>>   withLength: Boolean = true;
>>>
>>
>> How should a string without a length be read back?
>>
>> DoDi
>>
>> I didn't see DoDi's email anywhere in the thread, though it seems like
there're two threads anyway:
"Re: [fpc-devel] Method for write string into TStream" and "[fpc-devel]
Method for write string into TStream"

Anyways, answering DoDi's question.
It definitely won't be able to read a string without a size, but it doesn't
mean that the string size should immediately precede the string content.
So maybe a modification like this could help

procedure TStream.ReadAnsiString(knownsize: Integer=-1)
   if knownsize<0 then
     TheSize := ...readsize
  else
     TheSize := knownsize

thanks,
Dmitry
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to