Reader small image

You're reading from  Expert Delphi - Second Edition

Product typeBook
Published inFeb 2024
Reading LevelExpert
PublisherPackt
ISBN-139781805121107
Edition2nd Edition
Languages
Right arrow
Authors (2):
Marco Cantù
Marco Cantù
author image
Marco Cantù

Marco Cantù is an experienced Delphi expert, who started working with the product since its introduction in 1995. He is currently working as a Product Manager for RAD Studio at Embarcadero Technologies, an Idera company. Prior to that, Marco was a Delphi trainer and consultant for Wintech Italia. Over the years, Marco has written 20 books on Delphi, from the classic Mastering Delphi series to the recent Object Pascal Handbook. Marco has been a speaker at many Delphi and programming conferences worldwide, including over 10 Borland US Conferences, the Software Development Conference, Borland European conferences, EKON (Germany), DCon (UK), Conference to the Max (Holland), DelphiTage, the Italian Delphi Day, and a few editions of Delphi Developer Days. Marco is based in Italy.
Read more about Marco Cantù

Paweł Głowacki
Paweł Głowacki
author image
Paweł Głowacki

Paweł Głowacki was Embarcadero's European Technical Lead for Developer Tools. Previously, Paweł spent over 7 years working as a senior consultant and trainer for Delphi within Borland Education Services and CodeGear. Apart from working with Embarcadero customers across the region, he represented Embarcadero internationally as a conference and seminar speaker. Paweł passed away in mid-December 2017, but he is alive in the hearts of the Delphi developers community, worldwide.
Read more about Paweł Głowacki

View More author details
Right arrow

Mind Your Language

The Object Pascal language used in Delphi is constantly evolving. With every new version of Delphi, there are new features added to the language. Even though there are different Delphi compilers for each of the platforms, the language is the same. Minor differences depend on whether the target platform is 32-bit or 64-bit, and some other platform nuances. But in almost all cases, the same source code compiles and works across all platforms. This wasn’t the case in the early days of Delphi mobile compilers, which implemented Automatic Reference Counting (ARC) and other features not found in the desktop counterpart.

Fluency in using the Object Pascal language (also known as the Delphi language) is a key skill for every Delphi developer. It’s easy to underestimate how a good knowledge of the language can make you a better (and faster) developer.

This chapter will cover the following:

  • Do you speak Object Pascal?
  • The Object Pascal language...

Do you speak Object Pascal?

The Pascal language was designed to teach good programming practices, and its modern counterpart, the Object Pascal language, in use today, still holds true to some of the core tenets in terms of readability and clarity. The Object Pascal language in today’s Delphi is a high-level, modern, strongly typed compiled language that supports structured and object-oriented programming.

To solve a problem using a computer, you need to define a finite set of actions that operate on certain data – or in other words, to define an algorithm. An algorithm expressed in a programming language is a computer program and its actions are described as programming language instructions.

One or more actions that are performed on certain data can be encapsulated in Object Pascal language as a routine or a class. In most programming languages, routines are called functions. In Object Pascal, if a function does not return a value, it is called a procedure. Classes...

The Object Pascal language phrasebook

This book is aimed at Delphi programmers with some previous Delphi experience. The Object Pascal language of Delphi keeps evolving and knowing it well is of primary importance to every, even experienced, programmer. Not all the concepts that you can find in many Object Pascal tutorials are discussed here, but the idea is to have a solid understanding of some of the fundamental language concepts, with a focus on newer constructs.

Tokens

Tokens are the smallest meaningful pieces of text that a compiler understands. The tokenization is the very first thing that the compiler does when starting to process a source code file. There are different types of tokens, including identifiers, numbers, string constants, and special symbols. An Object Pascal program is made up of tokens and separators. A separator is either a blank space or a comment. There must be at least one separator between tokens.

In an Object Pascal source code, you can use any...

Summary

In this chapter, we have covered different basic as well as more advanced elements of the Object Pascal language used in Delphi. There are many tutorials and language primers that cover all elements of the language in detail. A good and deep knowledge of the language is important to be able to master Delphi, but this chapter should have helped you cover some of the basics and touched upon some of the features used later in the book.

In the first part of the chapter, we reviewed the structure of a typical Delphi application from the memory game app that we will build in the next few chapters. The second part of the chapter covered select elements of the Object Pascal language, such as type helpers, generics, and anonymous code, that are needed to better understand the code that comes with the Delphi installation and you need to use very frequently, such as generic lists of objects.

In the next chapter, we are going to build on our language knowledge and review the functionality...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Expert Delphi - Second Edition
Published in: Feb 2024Publisher: PacktISBN-13: 9781805121107
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (2)

author image
Marco Cantù

Marco Cantù is an experienced Delphi expert, who started working with the product since its introduction in 1995. He is currently working as a Product Manager for RAD Studio at Embarcadero Technologies, an Idera company. Prior to that, Marco was a Delphi trainer and consultant for Wintech Italia. Over the years, Marco has written 20 books on Delphi, from the classic Mastering Delphi series to the recent Object Pascal Handbook. Marco has been a speaker at many Delphi and programming conferences worldwide, including over 10 Borland US Conferences, the Software Development Conference, Borland European conferences, EKON (Germany), DCon (UK), Conference to the Max (Holland), DelphiTage, the Italian Delphi Day, and a few editions of Delphi Developer Days. Marco is based in Italy.
Read more about Marco Cantù

author image
Paweł Głowacki

Paweł Głowacki was Embarcadero's European Technical Lead for Developer Tools. Previously, Paweł spent over 7 years working as a senior consultant and trainer for Delphi within Borland Education Services and CodeGear. Apart from working with Embarcadero customers across the region, he represented Embarcadero internationally as a conference and seminar speaker. Paweł passed away in mid-December 2017, but he is alive in the hearts of the Delphi developers community, worldwide.
Read more about Paweł Głowacki