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
      Result.FOwnerName := Format('%s, %s', [Arg1.FLast, Arg1.FFirst]);
      Result.FPetNames := Arg2.Op.Select<String>(
        function(Arg1: TPet): String begin Result := Arg1.FName; end);

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

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


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 …


  1. 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. 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…

  3. 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.

  4. 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 😉

    1. 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.

  5. 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”.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.