[fpc-devel] Method for write string into TStreamt

Dmitry Boyarintsev skalogryz.lists at gmail.com
Mon Jul 21 14:28:48 CEST 2014


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;
);

thanks,
Dmitry


On Mon, Jul 21, 2014 at 5:34 AM, Marco van de Voort <marcov at stack.nl> wrote:

> In our previous episode, Sven Barth said:
> > > Do you think, that something similar can be added also in FPC ?
> >
> > There is already a WriteAnsiString (
> >
> http://www.freepascal.org/docs-html/rtl/classes/tstream.writeansistring.html
> > ) with the difference that it also writes out the length. Adding an
> > additional overload (especially with a name like WriteString) would IMHO
> be
> > confusing because of this.
> >
> > Nothing stops you though from writing a class helper that adds a
> > WriteString method to TStream.
>
> (Except the fact that you can only have one class helper per class?)
>
> Maybe writebinansistring would be a good name.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140721/501334f1/attachment.html>


More information about the fpc-devel mailing list