[fpc-pascal] Options for enabling output buffering
XHajT03 at mbox.vol.cz
Fri Dec 12 17:30:54 CET 2008
On Fri, December 12, 2008 14:35, Michael Van Canneyt wrote:
> On Fri, 12 Dec 2008, leledumbo wrote:
>> I'm tired of writing:
>> all the time in every programming contest I follow. Wouldn't it be
>> better to
>> provide an option or a define or whatever to enable output buffering?
> Flushfunc has nothing to do with output buffering ?
> SetTextBuf controls the buffering.
If the output goes to console (no redirection to file) _and_ FlushFunc
doesn't point to nil, it gets called after every Write(Ln) - see
fpc_Write_End in /rtl/inc/text.inc.
However, I'm not sure whether it would be appropriate to create a special
option just for the use case "participation in contest"... Remember that
for the real life situations where the speed of console output may be a
limiting factor, one can always decide to redirect the output to a file or
e.g. minimize the window (which would speed up the output as well, at
least with some target platforms). Moreover, the typing saved by replacing
the fragment above with a call to something like
"ForceTextOutputBuffering" (even if that's implemented in unit System and
thus no uses clause is necessary) is probably negligible... Moreover,
users interested in saving few keypresses can create a unit doing this in
its initialization part, so that the fragment could be replaced with
something like "uses Buffering" only.
More information about the fpc-pascal