skalogryz: and yes and no. I need to code that you post to work(is this already can achieved, can you give link to full example?).
You can achieve something like this using class helpers.
Where a helper would re declare "Items" property adding a new way of accessing variables.
BUT in fpc 2.6.4 this would close the original "Items".
Not sure, if it has been changed in fpc 3.0.0 and/or fpc-trunk, but I know that there's a discussion to allow using of multiple class helpers.
the example:
type
TMyClass = class(TObject)
protected
function GetInt(const idx: integer): Integer;
procedure SetInt(const idx: integer; avalue: integer);
public
property Items[AIndex: integer]: integer read GetInt write SetInt; default;
end;
THelpYourSelf = class helper for TMyClass
protected
function GetStr(const idx: string): Integer;
procedure SetStr(const idx: string; avalue: integer);
public
property Items[Aindex: string]: integer read GetStr write SetStr; default;
end;
yet again, in FPC 2.6.4 it will work, but only for separate units.
Thus you will be able to do
m [1]:=5;
in a unit that doesn't use the helper.
However, if a unit uses the unit with the helper declaration the only way to access properties would be
m['hello']:=5;
It might be less strict in fpc 3.0.0 or fpc-trunk