Skip to main content

blur-boxes-containers

Inline variables declaration is a feature introduced in Delphi Rio 10.3. What is it?

In short, it is the possibility to declare a variable in any line of your code. That is, you can declare a variable this way, within the begin..end block:

procedure Test;
begin
var I: Integer;
I := 22;
ShowMessage (I.ToString);
end;

A lot of people already understood how this feature works, but did not understand why it is interesting. In this article, I will show you this new feature with a focus on the advantages it brings.

actor-adult-businessman

Embarcadero has just released a new Delphi Rio version (which means also Rad Studio and C++ Builder): version 10.3.2. It’s a minor update – meaning product codename is still “Rio”, and it’s binary (DCU) compatible with previous 10.3.1 version.

Why then, an article about a minor update? Usually minor updates contain just bug fixes and small improvements, however it’s not the case of this one. I will mention here two improvements that I personally found significant. It’s also worth mentioning that Embarcadero has recently published the updated Rad Studio roadmap – May 2019 which lists the probable new improvements in upcoming major versions. Now to the improvements in this release:

delphi-memory-leaks

A memory leak happens when your application allocates a space in memory and never frees it again.

How memory leaks happen in Delphi

In a Delphi application, memory spaces are allocated and released all the time. This is often done automatically by the compiler or by the RTL – for example, when allocating variables of primitive types, parameters that are passed to functions, etc. – and we usually do not have to worry about it.