TZDB 1.8 — 13 November 2012 Database (2012j)

A new version of TZDB has been release (1.8.121113). This version adds some very small changes. The biggest update is the bundled database version.

Grab the latest version here, and view the latest changes here.

 

TZDB is an open source project that provides Delphi (7+) and FreePascal (2.0+) users with a “built-in” timezone database. The same source of data is used in most Unixes, Java, MacOS and multiple other projects out there.

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 …

Get over the FreeAndNil thing already!

‘Nuff Said!

Ping 2012!

Yes,  I am still here.

2011 was a very challenging year for me: in January 2011 I have been offered a very tempting position a company and I have accepted it. It’s a very small “services” company but with large expansions plans. The whole 2011 I was busy building a new system, maintaining some old ones (and gradually deprecating those in favor of the new one). It was really challenging and most of all time consuming. I had barely any free time for myself and when I had any I spent it as personal relaxation time.

The sad part about 2011 is that I did not get any chance to work on my open source projects (except the small updates to TZDB package). This year, hopefully, things are going to settle down work-wise and I will start getting more free time to work on my projects again!

I would like to give a small update about each project and what to expect from them in the future:

  • DeHL — A collection of code built around the concept of “type objects”. Unfortunately, DeHL only stirred some architectural interest in the Delphi community. It did not actually attract  many active users or contributors. If your code is not used in real life applications then it’s kind of useless. The good part is that it’s open source (BSD) and anybody doing a Google search can wind up there and download any piece of code for his/her use. Also, DeHL was a very good compiler “test case” in Delphi 2009/2010/XE time frame. I used it while working for Embarcadero a lot and it always revealed bugs and problems that got fixed internally. And finally, DeHL offered me the chance to learn some design principles I had never used before which ultimately made me a better programmer.But, unless someone steps up and takes over, DeHL is effectively dead.
  • TZDB — This project is alive. It’s a small project wise a very clear scope that was realized 2 years ago. I am only running a tool to generate new time zone definitions from time to time. Other than that TZDB is alive and kicking.
  • Collections — A collection of generic containers. What can be more exiting? (for me at least).  Well, I have on my machine a half-finished version 2.0. I have never completed it because it basically rips open some of the initial designs. Initially I inspired from .NET and Delphi collections classes to make a hybrid. Then I worked in Java and noticed that “Java’s way” is also a good way to go. So 2.0 tries to combine concepts of all three major players. This project is temporarily on hold until I find my direction.

The good thing about 2011 is that I had the chance to use all new shiny .NET technologies I haven’t touched before (I was a .NET 2.0 user before). This means, actual LINQ (collections and SQL) coding, WCF, WPF and all that stuff. This gave me a broader perspective on things. This also means that my most wanted Delphi feature for 2012 is anonymous types and lambdas. Hopefully we will see these features and we can build some very interesting and time-saving solutions around them.

2012

I never make new year’s resolutions because I know I would not keep them. This being said, I hope I can get my act together and finally finish Collections 2.0.

 

Happy and a Fruitful New Year!

TZDB 1.7 with 27 June Database

After a few months of inactivity I give you the latest update to TZDB featuring the last published TZ database. This realease also fixes a bug in the importer that could not properly read only hour based offsets which resulted in wrong calculations for some timezones.

For people trying to user Etc\xxxxx time zones. Those time zones have their sign inverted as specified by POSIX. This means that Etc\GMT+2 is actually GMT-2. This is not a bug in TZDB, it’s just the way these pseudo-timezones are defined.

 

For those unaware: TZDB is an open source project that provides Delphi (7+) and FreePascal (2.0+) users with a “built-in” timezone database. The same source of data is used in most Unixes, Java, MacOS and multiple other projects out there.

Grab the latest version here, and view the latest changes here.

Variant Invoke and RTTI

I was “spring cleaning” my temporary project directory on my hard drive today and I found a half-finished implementation of a dynamic dispatch for objects based on new RTTI (Delphi 2010+). I spent some time and fixed the last issues I had and now I think it’s ready to be published.

All the code is enclosed in a single unit (there’s not that much code actually) that exposes one function called “AsDynamic“. This method expects a normal non-nil object, a lifetime management flag and returns a custom Variant value.  The Variant can be used later on to dynamically invoke any method/property on that object.

The following example shows a wrapped TStringList object:

var
  LVarList: Variant;
begin
  { Create a new String List and wrap it into a Variant. By default the Variant will also take care about freeing the object. }
  LVarList := AsDynamic(TStringList.Create);

  { Add two strings to the string list. Note that Add() is called dynamically here. }
  LVarList.Add('Hello World!');
  LVarList.Add('Cool string');

  { Make the list sorted (also dynamically) }
  LVarList.Sorted := True;

  { ... And finally write the contents of the list }
  WriteLn(LVarList.Text);
end.

I don’t see any practical uses this code but it’s good for learning purposes. It can also be a simplified way of treating the cases when one has to execute the same code on classes that do not share a common ancestor or cannot implement an interface.

Just a quick note on what you can see inside the unit:

  • Defining a custom Variant type by extending TInvokeableVariantType and providing the proper support code.
  • An intermediate object and an interface that contain the wrapped object and RTTI structures needed for dynamic invoke. The custom Variant type carries over this object (actually an interface reference).
  • TValue to Variant and Variant to TValue conversion. Since the dynamic dispatch uses variants for arguments a conversion is required in both directions. This is simple in most cases but rather complicated for var and out parameters.

Note that dynamic dispatch as implemented by Delphi has quite a few restriction in what types are allowed and how exactly those values are passed to the invoked methods. For example literals are passed by value and variables are passed by reference (not always!). This is due to the nature of “not knowing” what exactly the method behind expects. As an example, you cannot pass a String by reference while a WideString variable is always passed by reference.

The code can be found here: Dynamic Object Dispatch (1059)

TZDB 1.7 database 14 March

I have finally managed to get some free time on my hands and released the latest update to TZDB containing the latest DB (from 14 March). As usual, no code changes, just data updates.

For those unaware: TZDB is an open source project that provides Delphi (7+) and FreePascal (2.0+) users with a “built-in” timezone database. The same source of data is used in most Unixes, Java, MacOS and multiple other projects out there.

Grab the latest version here, and view the latest changes here.

Twitter

I just joined “twitter-dom” as “pavkam“. Not sure on what I’m gonna post but at least I’ll give it a try :)

TZDB 1.7.110207 and Collections 1.1.1

TZDB 1.7.110207

No code changes, just an updated DB from “The tz Database“. There are a small number of changes there so upgrade only if you want to stay 100% up to date. I would just recommend you skip it. As usual, you can get the latest version here.

Collections 1.1.1

This is a bug fix release that addresses the following issues:

  1. No possibility to remove an value from a list or associative collection without invoking the “removal procedures”. This results in freed objects for object based collections. In pre-1.1 versions this wasn’t necessarily an issue. (Thanks Mason for the report, hope this unblocks your scripting project)
  2. Removal procedures were not invoked for bidirectional dictionaries.
  3. TObjectMultiMap<TKey, TValue> still used a “class” restriction on TValue type parameter.
  4. Fixed Delphi 2010 build. Note that by “fix” I mean — disabled Collections.Dynamic code and TBitSet class. Cannot make the compiler accept those (circular unit problems that were fixed in XE).

Get the bug fix release here.

Collections 1.1 is out

I’m proud to present version 1.1 of Collections package.



The major highlights of this release are:

  • TLinkedDictionary<TKey, TValue>, same as the standard dictionary but with predictable insertion order.
  • TLinkedStack<T>, same as standard set but with some predictability in element order.
  • TBitSet, a sorted set designed to store 16-bit numbers only.
  • TBidiDictionary<TKey, TValue>, a dictionary that enforces one key, one value on both ends.
  • TSortedBidiDictionary<TKey, TValue>, a sorted bidirectional dictionary.
  • TDoubleSortedDictionary<TKey, TValue>, a bidirectional dictionary sorted on both keys and values.
  • TSortedLinkedList<T>, a linked list with automated sorting.
  • RTTI based selectors. See overloads of Op.Select.
  • A rewrite of TLinkedList<T>, TLinkedQueue<T> and TLinkedStack<T>.
  • TArraySet<T> is not a sorted set and optimized a lot.
  • Multiple optimizations all over the place.
  • A new Op.GroupBy<T> operation.
  • Some internal cleanup.
  • Documentation fixes (Thanks Denisa once again).

On the project organization side, the project home page has got quite some love:

  • Three simplified diagrams of classes and interfaces in Collections.
  • A FAQ page that I hope will be useful to people. If you have a question not answered there please leave a comment and I will respond ASAP.
  • A page that states the differences between this project ans stock RTL collections.
  • A list with short descriptions for all Enex operations supported by collections.
  • A detailed “map” of all collections provided by the project with explanations of when to use, some implementation details and etc useful information that can help you better chose the collection you need.

On the documentation side of things, you will find two sample projects in the bundle. Only two at the moment, will add more when I have enough free time to.

Get the latest version or view the changelog!