Delphi anonymous methods are …

… too fat.

Surely writing code like this gets frustrating very fast. I want my lambdas!!

  { Lovely, isn't it? }
  LGroupJoined := LOwners.Op.GroupJoin<TPet, TPerson, TOwnedPets>(LPets,
    function(Arg1: TPerson): TPerson begin Result := Arg1; end,
    function(Arg1: TPet): TPerson begin Result := Arg1.FOwner; end,
    function(Arg1: TPerson; Arg2: ISequence<TPet>): TOwnedPets
    begin
      Result.FOwnerName := Format('%s, %s', [Arg1.FLast, Arg1.FFirst]);
      Result.FPetNames := Arg2.Op.Select<String>(
        function(Arg1: TPet): String begin Result := Arg1.FName; end);
    end
  );

  for LOwnedPets in LGroupJoined do
  begin
    WriteLn('Person ', LOwnedPets.FOwnerName, ' owns: ');
    Write('    ');

    for LName in LOwnedPets.FPetNames do
      Write(LName, ', ');

    WriteLn;
  end;

In other news, there is a working version of Collections 2.0 in the SVN. Most of the changes were sitting on my hard drive for a year now. I just made sure that the last touches are applied and that this version compiles in Delphi XE2. I have also applied a few fixes that enabled the package to work in 64 bit environment.

 

Be advised: The unit tests are completely broken. I have no short term plans on making them work. The amount of time needed for that is staggering. I am currently focused on features so I won’t touch them in a while.

 

P.S. I have to say that I am very disappointed with the quality of the IDE when generics are involved. I had countless unpleasant problems in the past but was expecting things to get better in XE2. Not so. My IDE froze countless time when trying to edit some source files. Whenever I would type a “.” or a “(” it would be gone for good. This makes me wonder whether Collections will be usable at all to you guys. With such buggy support I can predict only crashes. And don’t get me started on the EXE size …

10 Responses to 'Delphi anonymous methods are …'

  1. Moritz Beutel says:

    Still using XE, still happy :)
    I agree about the lambdas though. Right now I’m doing a little project in C#, and I enjoy using lambdas, LINQ, persisting any object graph to a human-readable file with no extra work, not having to make up object ownership graphs etc.

  2. alex says:

    Coming from the same environment. Using a lot of LINQ at my current job. Makes life a lot easier.

  3. Eric says:

    Turn off error insight and the symbol insight, however is called the thing that provides symbol info when the mouse hovers a symbol. They must leak or corrupt memory when operating on incorrect code (and code is almost always incorrect when you’re editing it), and after sometime, you just get random crashes in the IDE.

    For generics size, well, not much to do IME beyond keeping your generics as small as possible, and/or have them be only thin wrappers against non-generic containers whenever feasible.
    Using generics everywhere quickly leads your executables into dozens of megabytes for relatively simple stuff…

  4. alex says:

    Kinda defeats the whole purpose of this project. I’m going to keep it as an “experimental learning” facility for whoever wants to read the source code at this point.

  5. Finally someone who shares my experience when working with code that contains generics. I cannot remember how often either my IDE freezes or I get some internal compiler error which only can be resolved by restarting the IDE.

    As for the changes I like the renaming of TEnexCollection to TSequence ;)

    • alex says:

      The situation was much worse before the 2010 release. But I managed to create good test cases of the guys to use when fixing the IDE/compiler.

      There is a problem in the compiler that prevents it to properly compile generics when circular dependencies are found. And apparently there’s nothing that can be done about that with the current compiler architecture.

  6. nedko says:

    ooh dude.. using XE and i’m fed up with all these “Internal compiler error”. Every time I make syntax/semantic/whatever error in the anonymous method it punishes me by urging me to find the error myself. I hate “internal compiler error”.

  7. Warren P says:

    I think that an alternative code-completion engine for Delphi could be a good solution to the code completion bug.

    Warren

  8. This is beneficial when it comes to tailoring a study plan.. This is designed to assess writing,Trevor Siemian Jersey, verbal, quantitative, analytical and reading skills of people. If you delay paying, eventually it will halter the whole process and the work will be equally affected.It is imperative that you do not create a website in vain. You have to push your own limits and you will see the outcomes in a few weeks. With facilities like ornate dining rooms for hosting banquets and a Jacobean

Trackbacks/Pingbacks
  1. […] 2010 (the WiKi got removed at the end of 2010, but version r528 still has the WiKi). The same holds for his project delphi-coll – Generic collections library for Delphi 2010 and XE which […]

Leave a Reply to Warren P Cancel reply

Your email address will not be published.