Which language elements can be annotated using attributes language feature of Delphi?

Interesting question! You can declare attributes on almost anything, the problem is retrieving them using RTTI. Here’s a quick console demo of declaring custom attributes for: Enums Function type Procedure type Method type (of object) Aliased type Record type Class type Record type that’s internal to a class Record field Record method Class instance field … Read more

Why is drawing a line less than 1.5 pixels thick twice as slow as drawing a line 10 pixels thick?

Summary: Antialiasing subpixel thickness lines is hard work and requires a number of dirty tricks to output what we intuitively expect to see. The extra effort you’re seeing is almost certainly due to antialiasing. When the line thickness is less than one pixel and the line doesn’t sit squarely at the center of a row … Read more

Fluent interface in Delphi

Everybody is just writing about negative issues so let’s stress some positive issues. Errr, the only positive issue – less (in some cases much less) typing. I wrote GpFluentXMLBuilder just because I hate typing tons of code while creating XML documents. Nothing more and nothing less. The good point with fluent interfaces is that you … Read more

Delphi – Equivalent to C#’s ternary operator? [duplicate]

Of course you can use IfThen(SomeBooleanExpression, IfTrueReturnValue, IfFalseReturnValue) where the return values are numeric (uses Math) or string (uses StrUtils). But notice that this will evaluate both arguments in all cases — there is no lazy evaluation, so it is not as efficient as the ?: operator in C#, where only the right operand is … Read more

Advice for converting a large monolithic singlethreaded application to a multithreaded architecture?

You have a big challenge ahead of you. I had a similar challenge ahead of me — 15 year old monolithic single threaded code base, not taking advantage of multicore, etc. We expended a great deal of effort in trying to find a design and solution that was workable and would work. Bad news first. … Read more

How can Delphi ‘string’ literals have more than 255 characters?

why did not delphi give any error saying the length is beyond 255 for myExtremlyLongString? You have your answer a bit down in the text in section Long String (AnsiString). In current versions of Delphi, the string type is simply an alias for AnsiString, So string is not limited to 255 characters but a string … Read more