Visit site The Programming Works
May 2011
1
vote
Generic musings 2
The Programming Works
– It was pointed out in the comments to my previous post that my simple generic sorting routine contains additional overhead compared to TArray Rtl code (Generic.Collections & Generic.Defaults units) because RTTI is used inside the loop. Yes, that is true. Let try to improve the code by taking ...
1
vote
Generic musings
The Programming Works
– Delphi (as Pascal descendant) has always had powerful type system. Consider the following sample code implementing simple insertion sort algorithm (I use Delphi 2009): unit InsSort; interface type TItem = Integer; TArray = array of TItem; procedure InsertionSort(var A: TArray); ...
11
votes
Installing Virtual Treeview
The Programming Works
– Delphi component’s package installation procedure has always been a mess. If you don’t rely on self-made “automated” installations that just copy compiled binaries and do some registry patches that could easily destroy your Delphi installation beyond repair you should do ...
April 2011
7
votes
Best 1st April joke. Ever.
The Programming Works
– My regards to lazarus.su (in Russian). It’s 1st April post was: Lazarus developers announced that the IDE source code is closed and sold to Embarcadero. Under the unconfirmed information the last Lazarus version 0.9.30 will become the base for the next Delphi release – FPC Edition. ...
February 2011
2
votes
How to generate HTML Help with Doc-O-Matic Express
The Programming Works
– XMLDoc in-source documentation style is becoming popular among Delphi open-source projects. There is also very good Delphi Documentation Guidelines document which describes what XML tags should be used for in-source XMLDoc-style documenting comments and how to use these tags. Unfortunately currently ...
6
votes
TInteger
The Programming Works
– Since the introduction of operator overloading in Delphi one can easily define custom data types that support arithmetic operations. For example it is quite easy to implement arithmetic of complex numbers like this: type PComplex = ^TComplex; TComplex = record Re, Im: Extended; class ...
November 2010
3
votes
Delphi interfaces without reference counting
The Programming Works
– Any interface in Delphi inherits from IInterface (which is a nickname for IUnknown). It is nice for reference-counted interfaces, but sometimes we do not need reference counting at all. Consider the following example: unit IValues; interface type IValue = interface(IInterface) function ...
September 2010
9
votes
Synchronization in Delphi TThread class
The Programming Works
– VCL sources is a very interesting reading, if you have a time for it. Many Delphi programmers (like me) use VCL TThread class as a simple wrapper for WinAPI kernel thread object, avoiding to use Synchronize and Queue methods by using a custom message processing instead. Still it is worthwhile to ...
August 2010
3
votes
Understanding Threads: Atomic Operations and Memory Ordering
The Programming Works
– A common question about threads is: “I need a read/write access to a variable from two or more threads. Should I protect an access to a variable by critical section?” A simple answer is: yes, if you want to be on the safe side always protect the variable by a critical section. A deeper answer ...
3
votes
Thread synchronization in Windows XP and Vista
The Programming Works
– An implementation of the thread locks have changed between Windows XP and Vista. To make a long story short, XP locks were fair; starting from Vista (and also Windows 2003 SP1) thread locks are unfair. A lock fairness means that the threads that tries to hold a lock (for example, to enter a ...
July 2010
0
votes
A String of Byte?
The Programming Works
– Dynamic arrays are implemented in Delphi as lifetime-managed reference types without “copy-on-write” support. What does it mean on practice can be shown by the following code: program Project1; {$APPTYPE CONSOLE} type TIntArray = array of Integer; var A, B: TIntArray; begin ...
6
votes
The Emperor’s New Clothes
The Programming Works
– I had a very disappointing discussion with Embarcadero employees on EDN forums recently on the subject already covered in CR blog or Deltics blog. I have no desire to give a link to the EDN thread – the thread is locked now, it does not bring honour to its participants. Instead I give a link ...
0
votes
Delphi interfaces on binary level
The Programming Works
– An interface reference in Delphi is a pointer to pointer to an interface method table (IMT). That follows the COM specifications and is a good starting point to understand what Delphi interfaces are on binary level. Delphi interfaces can be made 100% compatible with COM specifications, but that is ...
June 2010
0
votes
A fUnNy StRiNg
The Programming Works
– CR in his recent post about the quality of Delphi help discussed the StrUpper/StrLower code example. I was interested why the original D7 example causes an access violation while the similar D2009 example runs without AV. So I have written the following tests (in Delphi 2009): {$WRITEABLECONST OFF} ...
0
votes
Delphi class helpers: a practical example.
The Programming Works
– Using the standard VCL TFileStream class you can’t set a sharing mode for a new file until Delphi 2010. A trick like this var Stream: TStream; begin Stream:= TFileStream.Create('TEST', fmCreate or fmShareDenyWrite); ... is useless since fmCreate or fmShareDenyWrite = fmCreate, and you ...




