Probably the world's first Delphi 8 class operators example

Are you looking for an example in using Delphi 8's class operators?

Well, the source codes in the RTL had some class operators stuff, but there were no class operator demos shipped with the product.

That being said, I investigated into the issue of that, and the following example was written by me. It's probably the world's first Delphi 8 class operators example, outside of Borland.

Initially, I wanted to write something like

Degree = packed record;

Fahrenheit  = packed record(IConvertible)
    class operator  Implicit(AValue: Degree): Fahrenheit;
end;

Degree  = packed record(IConvertible)
    class operator  Implicit(AValue: Fahrenheit): Degree;
end;

But then, I discovered I couldn't declare forward records, just as I could declare forward classes, or forward procedures, collectively known as forward declarations.

That being said, the following is a complete example to using class operators. The example demonstrates converting between degree celsius, degree fahrenheit and kelvin.

The example can be downloaded here.

Published Thu, 29 Apr 2004 @ 9:33 AM by chuacw
Filed under:

Comments

# Delphi 8 class operators example

Friday, April 30, 2004 12:39 AM by TrackBack

# re: Probably the world's first Delphi 8 class operators example

Friday, April 30, 2004 1:37 AM by chuacw

"Well, the source codes in the RTL had some class operators stuff, but there were no class operator demos shipped with the product."

Unless you count the VCL for .NET source code, which has many.

# re: Probably the world's first Delphi 8 class operators example

Friday, April 30, 2004 1:39 AM by chuacw

Come to think of it, I guess that's what you meant!

# re: Probably the world's first Delphi 8 class operators example

Friday, April 30, 2004 4:31 PM by chuacw

FTR, it's just "Kelvin" (K), not "degrees Kelvin" (°K)

# re: Probably the world's first Delphi 8 class operators example

Friday, April 30, 2004 4:46 PM by chuacw

Thanks for the correction, John.

Do you have a blog?

# Adventures in TDD. Part 1. The Setup

Sunday, May 02, 2004 3:55 PM by TrackBack

# re: Delphi and C# comparison

Tuesday, May 11, 2004 11:49 PM by TrackBack

# Adventures in TDD. Part 1. The Setup

Sunday, August 15, 2004 4:41 PM by TrackBack

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Enter the following code to ensure that your comment reaches the intended party:
Enter the numbers you see in the image: