Skip to content

New Argument Type for Format Function

Summary

The request is to add a new argument type, for example, "%O". The corresponding parameter for this argument is supposed to be an object implementing function ToString: String.

Why?

Consider this piece of code:

function LogRandomly(Prob: Double; Fmt: AnsiString; Args: array of const): Boolean;
begin
  if Prob < random() then
     Exit(False);
  WriteLn(Format(Fmt, Args));  
end;

Currently, one can make a call to this function by

LogRandomly(0.1, '%s', Obj.ToString)

and with the proposed argument, one can have

LogRandomly(0.1, "%O", Obj);
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information