#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
  private
    FValue: ISuperObject;
  public
    property Value: ISuperObject read FValue;
  public
    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;
  end;

Board footer

Powered by FluxBB