Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-08

rtl-generics: Suggestion and question

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

I've spend some time adapting my beta project to use the new rtl-generics classes, however, I have some issues regarding to TDictionary class. Let's go to a test using the example below:

=== begin code ===

var
  hash: TDictionary<string, string>;
begin
  hash := TDictionary<string, string>.Create;
end

=== end code ===

You may get the following compiler log:

=== begin log ===

generics.dictionariesh.inc(231,33) Hint: Parameter "AFrom" not used
generics.dictionariesh.inc(231,40) Hint: Parameter "ATo" not used
generics.dictionariesh.inc(54,27) Hint: Parameter "ACapacity" not used
generics.dictionariesh.inc(58,32) Hint: Parameter "AValue" not used
generics.dictionariesh.inc(69,28) Hint: Parameter "APair" not used
generics.dictionariesh.inc(87,36) Hint: Parameter "ASize" not used
generics.dictionariesh.inc(155,39) Hint: Parameter "AItems" not used
generics.dictionariesh.inc(155,71) Hint: Parameter "AKey" not used
generics.dictionariesh.inc(155,87) Hint: Parameter "AHash" not used
generics.defaults.pas(47,31) Hint: Parameter "ALeft" not used
generics.defaults.pas(47,38) Hint: Parameter "ARight" not used
generics.defaults.pas(69,35) Hint: Parameter "AValues" not used
generics.defaults.pas(69,56) Hint: Parameter "ALeft" not used
generics.defaults.pas(69,63) Hint: Parameter "ARight" not used
generics.defaults.pas(69,86) Hint: Parameter "AComparer" not used
generics.defaults.pas(78,42) Hint: Parameter "AValues" not used
generics.defaults.pas(78,72) Hint: Parameter "AItem" not used
generics.defaults.pas(79,11) Hint: Parameter "AFoundIndex" not used
generics.defaults.pas(79,39) Hint: Parameter "AComparer" not used
generics.defaults.pas(80,7) Hint: Parameter "AIndex" not used
generics.defaults.pas(80,15) Hint: Parameter "ACount" not used
generics.defaults.pas(143,27) Hint: Parameter "AValue" not used
generics.defaults.pas(47,31) Hint: Parameter "ALeft" not used
generics.defaults.pas(47,38) Hint: Parameter "ARight" not used
generics.defaults.pas(69,35) Hint: Parameter "AValues" not used
generics.defaults.pas(69,56) Hint: Parameter "ALeft" not used
generics.defaults.pas(69,63) Hint: Parameter "ARight" not used
generics.defaults.pas(69,86) Hint: Parameter "AComparer" not used
generics.defaults.pas(78,42) Hint: Parameter "AValues" not used
generics.defaults.pas(78,72) Hint: Parameter "AItem" not used
generics.defaults.pas(79,11) Hint: Parameter "AFoundIndex" not used
generics.defaults.pas(79,39) Hint: Parameter "AComparer" not used
generics.defaults.pas(80,7) Hint: Parameter "AIndex" not used
generics.defaults.pas(80,15) Hint: Parameter "ACount" not used
generics.collections.pas(143,27) Hint: Parameter "AValue" not used
generics.defaults.pas(767,30) Hint: Parameter "ALeft" not used
generics.defaults.pas(767,37) Hint: Parameter "ARight" not used
generics.defaults.pas(768,35) Hint: Parameter "AValue" not used

=== end log ===

Those hints can be a problem when we also need to check the log from other classes, because it pollute the windows messages, so a suggestion is just to declare the "{$WARN 5024 OFF : Parameter "$1" not used}" in the rtl-generics units.

The question is regarding to TDictionary, because I'm not sure if it is a concrete class on its actual implementation stage (I'm using FPC from trunk). See the warnings below:

=== begin warns ===

generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "DoMoveNext"
generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "GetCurrent"
generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "DoMoveNext"
generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "GetCurrent"

=== end warns ===

I want to use the TDictionary in a beta project, but I'm not sure if today it is only for experimental purposes. :-/

Thank you!

Silvio Clécio

Reply by email

Maciej Izak
to silvioprog

2016-08-12 19:17 GMT+02:00 silvioprog :

Show quoted text 5 lines
Those hints can be a problem when we also need to check the log from other classes, because it pollute the windows messages, so a suggestion is just to declare the "{$WARN 5024 OFF : Parameter "$1" not used}" in the rtl-generics units.

The question is regarding to TDictionary, because I'm not sure if it is a

Show quoted text 20 lines
concrete class on its actual implementation stage (I'm using FPC from trunk). See the warnings below: === begin warns === generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "DoMoveNext" generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "GetCurrent" generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "DoMoveNext" generics.dictionaries.inc(158,92) Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc7DF95A99" with abstract method "GetCurrent" === end warns ===

Using WARN OFF for whole module is rather bad, but might be (temporary) the only solution. IIRC FPC has many bugs for switching off warnings / hints especially for generics. Compiler likes to report warnings/hints in specialization place/module (which each of reported warnings was disabled in structure declaration).

I want to use the TDictionary in a beta project, but I'm not sure if today it is only for experimental purposes. :-/

TDictionary is very stable and well tested. Feel free to use that structure it definitely should stay without many modifications (generally public interface is stable - compatibility with Delphi).

the only candidate to remove is :

procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition:
TOnGetMemoryLayoutKeyPosition);

which was used only for testing purposes, thanks to GetMemoryLayout you can see how looks memory layout for each kind of dictionary (we have many memory layouts, even more - we have unique de-amortized cuckoo hashing - http://arxiv.org/abs/0903.0391 declared as THashMap/TFastHashMap).

Best regards, Maciej Izak

Reply by email

silvioprog
to Maciej Izak

On Fri, Aug 12, 2016 at 3:51 PM, Maciej Izak wrote: [...]

Show quoted text 6 lines
Using WARN OFF for whole module is rather bad, but might be (temporary) the only solution. IIRC FPC has many bugs for switching off warnings / hints especially for generics. Compiler likes to report warnings/hints in specialization place/module (which each of reported warnings was disabled in structure declaration).

IIRC FPC has the {$PUSH}/{$POP} switches allowing to enable/disable switches, I would be happy if someone could confirm that.

TDictionary is very stable and well tested. Feel free to use that structure

it definitely should stay without many modifications (generally public interface is stable - compatibility with Delphi).

Awesome, I'm going to do it! :-)

Show quoted text 5 lines
the only candidate to remove is : procedure GetMemoryLayout(const AOnGetMemoryLayoutKeyPosition: TOnGetMemoryLayoutKeyPosition);

which was used only for testing purposes, thanks to GetMemoryLayout you can

see how looks memory layout for each kind of dictionary (we have many memory layouts, even more - we have unique de-amortized cuckoo hashing - http://arxiv.org/abs/0903.0391 declared as THashMap/TFastHashMap).

Great. Does TDictionary descendant from one of those classes?

Silvio Clécio

Reply by email

silvioprog
to silvioprog
silvioprog wrote 13 lines
On Fri, Aug 12, 2016 at 3:51 PM, Maciej Izak wrote: [...] > Using WARN OFF for whole module is rather bad, but might be (temporary) > the only solution. IIRC FPC has many bugs for switching off warnings / > hints especially for generics. Compiler likes to report warnings/hints in > specialization place/module (which each of reported warnings was disabled > in structure declaration). > IIRC FPC has the {$PUSH}/{$POP} switches allowing to enable/disable switches, I would be happy if someone could confirm that.

Oh, I'm wrong about POP/PUSH switches ^^' :

http://www.freepascal.org/docs-html/prog/progsu62.html#x69-680001.2.62

http://www.freepascal.org/docs-html/prog/progsu63.html#x70-690001.2.63

Silvio Clécio

Reply by email