#1 Re: Language » record and object issue in Delphi 2010 » 2012-04-26 16:51:19

Sorry for bubble up the old post.

IMO, it is very dangerous to initialize a record with FillChar. If you want to design a new record type, I recommend to make it immutable.

  // Example of an immutable record
  TIdentifier = record
    FValue: ISuperObject;
    property Value: ISuperObject read FValue;
    class function NullIdentifier: TIdentifier; static;
    class function StringIdentifier(const Value: string): TIdentifier; static;
    class function NumberIdentifier(Value: Integer): TIdentifier; static;
    class function FromValue(const Value: ISuperObject): TIdentifier; static;
    function ToString: string;

Board footer

Powered by FluxBB