Re: [fpc-pascal] Re: Generics - how to rewrite TOjectDictionary

2013-04-08 Thread dmitry boyarintsev
please disregard my last note about "avoiding the sanity check" On Mon, Apr 8, 2013 at 1:52 PM, dmitry boyarintsev < skalogryz.li...@gmail.com> wrote: > You can always use functions, to fight typecasting. > > function GetMyObject(dic: TStrings; const nm: string): TMyObject; > var > i : intege

Re: [fpc-pascal] Re: Generics - how to rewrite TOjectDictionary

2013-04-08 Thread dmitry boyarintsev
You can always use functions, to fight typecasting. function GetMyObject(dic: TStrings; const nm: string): TMyObject; var i : integer; begin if not Assigned(dic) then begin Result:=nil; Exit; end; i:=dic.indexof(nm); // replace with IndexOfName if necessary if (i<0) or (i>=dic.Count) or no

Re: [fpc-pascal] Re: Generics - how to rewrite TOjectDictionary

2013-04-08 Thread Sven Barth
Am 08.04.2013 10:18, schrieb Marco van de Voort: In our previous episode, Marius2 said: Yes, I have used it lots of times and its really the last choice if theres something available like the objectdictionary. In this case the dict is also the owner of the objects, it saves me the continious ugl

Re: [fpc-pascal] Re: Generics - how to rewrite TOjectDictionary

2013-04-08 Thread Marco van de Voort
In our previous episode, Marius2 said: > Yes, I have used it lots of times and its really the last choice if theres > something available like the objectdictionary. In this case the dict is also > the owner of the objects, it saves me the continious ugly typecasting, takes > care of the extra admin