Errors Using ThashSet from DeHL Collection Library

I am new to Delphi and I am trying to use the DEHL collection library. (see http://code.google.com/p/delphi-coll/ ) I have a bit of a problem with this in terms of the IDE. It compiles and works correctly, but Delphi XE shows errors wherever I use the HashSet library. The biggest complaint is that I cannot use code completion.

The first place I get the error is in the declaration of the object:

uses SysUtils, Windows, Collections.Base, Collections.Sets, Collections.Lists, adscnnct, adstable, uOtherClass; type OneClass = class(OtherClass) private _bad: THashSet<string>; // THashSet underlined _good: TList<string>; // No problems end; 

This error states: "Type arguments do not comply with restrictions"

I don’t think this is a setting, because I can use TList just fine, but here’s how I set it up: I copied the library to Projects / Libs / DeHLCollections / Library and compiled the library for projects / Libs / bin. I included the bin directory in my path to the global library, which made it compile and run. I tried adding everything (/ libs, / DeHLCollections, / Library) to it, and also hoping to get an IDE to help me, but it doesn't seem to help.

Anyway, to fix it, or do I just need to deal with it?

Using DeHL Collections version 1.1.1.119

+6
source share
1 answer

Welcome to problems using the downloaded Generics code. DeHL and generics work much better in Delphi XE than in any previous version of Delphi, but it's not the same as "you have no problem." The problems I'm experiencing are exactly like yours.

My opinion is that DeHL shows every sign that it was written by a master-programmer-dolphi, and that this is to some extent a beauty. It is also a source of great pain, not through one's fault.

Delphi contains not one or two, but at least three (maybe four?) Separate parsers, including a full compiler parser, and several IDE parsers used for things like Error Insight (the errors you see, even before creation) and code completion data analyzer. Each of them has different language support restrictions regarding generics. It is possible that DeHL could be written to avoid problems with the parser with all the various Delphi parsers. I have not seen a manual ever written that shows the limitations, but I would not be surprised if complex type declarations like TSomething<TSomething<ISomethingElse>,TBar<IFoo>> break more than a few of these parsers.

If you intend to use Generics very heavily, you can also disable Code Completion and Error Insight. You can also often save and be prepared to experience many problems with the compiler. And don't try to compile generic-heavy code and put it in packages. When I write code based on generics, I experienced a lot of URW and AV (internal compiler errors). I find that the Delphi compiler team does an excellent job of what is being reported, but that Generics are really the most stable for me when I limit myself to using Generics.Collections that come with Delphi and not using other generic code. It seems that you can write material using the generics functions, that the IDE and two-way tools and code completion are not yet fully ready for processing. This means that phenomenal space-based generating capacities stand behind the classic RAD IDE performance capabilities.

As they say, the latest DeHL sources from Subversion work fine for me and build and run without errors, but the very latest ZIP file source for the entire DeHL collection had problems for me.

I expect that over the next few releases of Delphi, whatever problems are found (and DeHL seems to be a great place to push the boundaries, and one of the reasons I am a big fan of this) will be fixed and you won’t be interested why heavy generics disrupt your IDE functions because they will all work again.

+6
source

Source: https://habr.com/ru/post/893113/


All Articles