Reserved words/pl

From Lazarus wiki
Revision as of 09:35, 27 August 2020 by Slawek (talk | contribs) (→‎Reserved words in Turbo Pascal: tłumaczenie na j. polski)
Jump to navigationJump to search

Deutsch (de) English (en) français (fr) polski (pl) русский (ru) 中文(中国大陆)‎ (zh_CN)

Słowa kluczowe poszczególnych trybów kompilatora podsumowano w następujący sposób:

Template:Uwaga

Zarezerwowane słowa w Turbo Pascal

W trybie Turbo Pascal występują następujące słowa kluczowe:

Słowo kluczowe Opis
and Operator logiczny wymagający spełnienia obu warunków, aby wynik był prawdziwy
array wiele elementów o tej samej nazwie
asm początek kodu napisanego w języku asemblera
begin początek bloku kodu
break wyjście z instrukcji case
case wybór konkretnego fragment kodu do wykonania na podstawie wartości
const deklaracja identyfikatora ze stałą wartością lub zmienną z zainicjowaną wartością
constructor procedura używana do tworzenia obiektu
continue pomija iterację w pętli for i wznawia wykonywanie od początku pętli
destructor procedura używana do zwalniania przydziału obiektu
div operator dzielenia liczby całkowitej
do używane do wskazania początku pętli
downto używane w pętli for do wskazania, że ​​zmienna indeksu jest zmniejszana
else używane w instrukcji if w celu zapewnienia ścieżki wykonania, gdy test if nie powiedzie się
end koniec bloku kodu, rekordu lub innych konstrukcji
false wartość logiczna wskazująca, że ​​test nie powiódł się; przeciwieństwo prawdy. Od FPC 3.0.0. False nie jest już słowem kluczowym.
file zewnętrzna struktura danych, zwykle przechowywana na dysku
for pętla używana do zwiększania lub zmniejszania zmiennej sterującej
function definiuje początek procedury, która zwraca wartość wyniku
goto służy do wyjścia z segmentu kodu i przeskoczenia do innego punktu
if testuje warunek i wykonuje zestaw instrukcji w oparciu o uzyskany wynik
implementation definiuje wewnętrzne procedury w module
in identyfikuje elementy w kolekcji
inline kod maszynowy wstawiany bezpośrednio do procedury
interface publiczna deklaracja procedur w module
label definiuje docelowy punkt skoku dla goto
mod operator używany do zwracania reszty z dzielenia liczb całkowitych
nil wartość wskaźnika wskazująca, że ​​wskaźnik nie zawiera wartości
not operator logiczny, który neguje wynik testu
object definiuje konstrukcję obiektu
of definiuje cechy zmiennej
on definiuje instrukcję obsługi wyjątków w części Except instrukcji Try
operator definiuje procedurę używaną do implementacji operatora
or operator logiczny, który pozwala na użycie jednej z dwóch opcji
packed wskazuje, że elementy tablicy mają zajmować mniej miejsca (to słowo kluczowe służy głównie do zapewnienia zgodności ze starszymi programami, ponieważ pakowanie elementów tablicy jest zwykle automatyczne)
procedure zdefiniuj początek procedury, która nie zwraca wartości wynikowej
program definiuje początek aplikacji. To słowo kluczowe jest zwykle opcjonalne.
record grupuje serię zmiennych pod jedną nazwą
repeat zamyka sekcję kodu w pętli aż do wystąpiennia instrukcji until, dopóki wynik testu jest prawdziwy
set pogrupuje kolekcję
shl operator do przesunięcia wartości w lewo; odpowiednik pomnożenia przez potęgę 2
shr operator do przesunięcia wartości w prawo; odpowiednik podzielenia przez potęgę 2
string deklaruje zmienną, która zawiera wiele znaków
then wskazuje początek kodu w teście if
to wskazuje, że zmienna for ma być zwiększana
true wartość logiczna wskazująca, że ​​test się powiódł; przeciwieństwo fałszu. Od FPC 3.0.0. True nie jest już słowem kluczowym.
type deklaruje rodzaje rekordów lub nowe klasy zmiennych
unit oddzielnie kompilowany moduł
until wskazuje na koniec testu instrukcji repeat
uses wskazuje nazywy modułów, których używa ten program lub moduł
var deklaruje zmienne
while testuje wartość i dopóki jest prawdziwa, wykonuje sekcję kodu w petli
with odwołuje się do zmiennych wewnętrznych w rekordzie bez konieczności odwoływania się do samego rekordu
xor operator logiczny, który zwraca prawdę, jeśli operandy nie mają tych samych wartości logicznych

Reserved words in Object Pascal

Object Pascal extends the (Turbo) Pascal language with both support for dealing more easily with objects (object orientation) as well as other newer/more advanced concepts (threads, etc).

In addition to the reserved words in Turbo Pascal, the following reserved words are available in Delphi mode as well:

Keyword Description
as
class
constref
dispose
except
exit
exports exports symbols which will be publicly available
finalization introduces an optional 'finalization' part of a unit.
finally part of a try - finally - end block
inherited calls function/procedure from ancestor class
initialization introduces an optional 'initialization' part of a unit.
is can be used as an operator or a modifier
library used in a shared library unit instead of the reserved word unit
new
on
out
property
raise causes an exception
self reference to an instance of a class
threadvar declare global variable to be thread local
try part of Try .. Finally or Try .. Exception block

Reserved words in Extended Free Pascal

The reserved words in Extended Free Pascal mode include:

Modifiers (directives)

Modifiers are not strictly reserved words; however they are used in the same way as reserved words.

See the Free Pascal Reference Guide for details.

Modifiers Description
absolute
abstract an abstract class cannot be instantiated, only inherited
alias
assembler pure assembler routine: routine is defined by asm … end
cdecl C declaration modifier
Cppdecl C++ declaration modifier
default For indexed properties to use them without specifying the property name
export
external
forward Allow a subroutine to be used before it is declared
generic class creation modifier
index
local A function/procedure modifier only usable with Linux (for Kylix compatibility)
name
nostackframe compiler hint: omit stack frame if possible
oldfpccall deprecated subroutine calling convention
override overriding of virtual functions
pascal use classic pascal calling convention
private private accessibility modifier, only class members can access data/functions/procedures
protected protected accessibility modifier, accessibility modifier, class members and inherited classes can access data/functions/procedures
public public accessibility modifier, public access to data/functions/procedures
published accessibility modifier, published properties are visible in IDE ar can be written to .lfm
read property read access
register define routine’s calling convention: pass first n parameters via GPRs
reintroduce
safecall subroutine calling convention
softfloat
specialize specialization of generic classes
stdcall subroutine calling convention
virtual describes a virtual method in OO programming
write property write access

Unsupported Turbo Pascal modifiers

Light bulb  Uwaga: These modifiers are supported in the DOS cross compiler present in the FPC development version

The reason why these modifiers are not supported is that these modifiers deal with 16 bit code for DOS. In other words, these modifiers have special meaning for 16 bit programming under DOS and Windows 3.x.

As Free Pascal does not support 16 bit code (only 32 and 64 bit), these modifiers are irrelevant in Free Pascal code.

far access addresses outside of the current 64KB segment
near access addresses in the current 64KB segment

More functionality

Apart from the language features provided by the reserved words/keywords mentioned above, there is a lot of functionality available for the programmer in the various libraries:

  • RTL: Run-Time Library, available for all FPC and Lazarus programs
  • FCL: Free Component Library: a core set of libraries available for Lazarus programs and usually for FPC (FPC can be compiled without it, but that only happens on purpose for low-memory embedded systems etc)
  • FPC Packages: other packages provided by FPC
  • Lazarus components: these are Lazarus components that can be dropped on a form and often based on FCL or FPC packages
  • Lazarus utility functions: e.g. the fileutil unit.

Apart from the libraries provided by FPC and Lazarus, there are more libraries/components available:

  • FPC user-supplied units: see the FPC wiki
  • Lazarus CCR: components
  • User-supplied code on the internet: see open source repositories like SourceForge and GitHub.

See also