Skip to content

[FR] Add SAFE keyword

Summary

When working with TCollection and TCollectionItem, I always override items[] property as

TNewCollection = class(TCollection)
public 
  property Items[Index: Integer] : TNewCollectionItem read GetItem write SetItem;

...

function TNewCollection.GetItem(index: integer): TNewCollectionItem;
begin
  Result := inherited GetItem(index) as TNewCollectionItem;
end;

procedure TNewCollection.SetItem(index: integer; value: TNewCollectionItem);
begin
  inherited SetItem(index, value);
end;

As you see, the TNewCollection.GetItem and TNewCollection.SetItem just redirect to parent function/procedure.

I suggest add new keyword SAFE as:

TNewCollection = class(TCollection)
public 
  property Items[Index: Integer] : TNewCollectionItem read GetItem write SetItem; SAFE; // <-- GetItem and SetItem are from TCollection

and if TNewCollection.GetItem and TNewCollection.SetItem does not exist => just call the parent function/procedure!

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information