- Expert Delphi
- Pawe? G?owacki
- 390字
- 2021-07-02 20:44:22
Do you speak Object Pascal?
The Object Pascal language has been designed for teaching good programming practices. It is a high-level, modern, and strongly typed compiled language that supports structured and object-oriented programming.
In order 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 performed on certain data can be encapsulated in the Object Pascal language as a routine or a class. In Object Pascal, routines are called functions. If a function does not return a value, it is called a procedure. Classes are the corner stones of object-oriented programming, which is the most important approach to building apps in Object Pascal. Objects group the data and the operations performed on this data together, providing encapsulation and reusability.
In the previous chapter, you learned about compilers. The job of a compiler is to process one or more files that contain the text of the programs that we write in a programming language and generate a binary file that can be loaded by an operating system and executed. Compilers may also generate other types of binaries, such as packages or services. In this chapter, we will focus on the contents of the files that contain the source code of our programs. Source code files are regular text files that can be opened in an arbitrary text editor. The default extension of a file that contains the Object Pascal source code is .pas. When you install Delphi, it will register itself with Windows as the default program for opening different file types related to Delphi programming, including .pas, .dpr, .dpk, .dproj, and a few more.
The source code file needs to contain proper content according to the rules of the programming language. If you try to compile a file that is not properly structured or that contains programming language errors, the compiler will stop the compilation and report an error message describing the location and nature of the error. Sometimes the error message might not be obvious, but we would typically get the name of the source file and the text line number where the error is located.