At 14.58 12/09/2004, you wrote:
  procedure CopyFile(SourceFileName, TargetFileName: string);
  auto
      s, t: TStream;
  begin
      s := TFileStream.Create(SourceFileName, fmOpenRead);
      t := TFileStream.Create(TargetFileName, fmCreate);
      t.CopyFrom(s);
  end;

what do you think about this, instead?

  procedure CopyFile(SourceFileName, TargetFileName: string);
  begin
      TFileStream.Create(TargetFileName, fmCreate).
          CopyFrom(TFileStream.Create(SourceFileName, fmOpenRead));
  end;

I love how C++ can create anonymous objects with the lifetime of the expression that invokes their constructor. The "with" construct, moreover, lets you perform multiple operations on the temporary object, and, borrowing from C#, it can be extended to declare variables in mid-function:

with <var1>: <type1> [ = <init1> ], <var2>: <type2> [ = <init2> ] do [...]


_______________________________________________ fpc-devel maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to