pascal.md: update
This commit is contained in:
parent
1fe8f53497
commit
f9c2fa55b0
1 changed files with 29 additions and 2 deletions
|
@ -4,11 +4,37 @@ Pascal is a procedural programming language created by [Niklaus Wirth](niklaus_w
|
||||||
Pascal was a popular choice for microcomputers in the 70's and 80's, even more popular than C initially (C was still quite an UNIX-only language)
|
Pascal was a popular choice for microcomputers in the 70's and 80's, even more popular than C initially (C was still quite an UNIX-only language)
|
||||||
due to its simple design, which allowed fast simple single-pass compilers.
|
due to its simple design, which allowed fast simple single-pass compilers.
|
||||||
|
|
||||||
|
In its "vanilla" form, Pascal is not any more complex than C, aside from having features that C doesn't have, such as range types
|
||||||
|
and nested procedures.
|
||||||
|
|
||||||
## Compilers
|
## Compilers
|
||||||
- [FPC](https://www.freepascal.org/) (Free Pascal Compiler): currently the most popular Pascal compiler with wide support
|
- [FPC](https://www.freepascal.org/) (Free Pascal Compiler): currently the most popular Pascal compiler with wide support
|
||||||
for different OSes and architectures, libre software.
|
for different OSes and architectures, libre software.
|
||||||
- Turbo Pascal: old compiler for DOS systems, proprietary
|
- Turbo Pascal: old compiler for DOS systems, proprietary.
|
||||||
- Delphi: proprietary, adds [OOP](oop.md) bloat
|
- Delphi: proprietary, adds [OOP](oop.md) bloat and exception handling.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
### Returning values from functions
|
||||||
|
```pascal
|
||||||
|
{ The "classical" way, assigning the return value to the function name }
|
||||||
|
function Square(n: integer): integer;
|
||||||
|
begin
|
||||||
|
Square := n * n;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Object Pascal and Delphi, assigning to special `Result` variable }
|
||||||
|
{ Enable with `-S2` in FPC }
|
||||||
|
function Square(n: integer): integer;
|
||||||
|
begin
|
||||||
|
Result := n * n;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ Return statement like }
|
||||||
|
function Square(n: integer): integer;
|
||||||
|
begin
|
||||||
|
Exit(n * n);
|
||||||
|
end;
|
||||||
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
### Hello world
|
### Hello world
|
||||||
|
@ -68,6 +94,7 @@ end.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
- [Free Pascal Wiki](https://wiki.freepascal.org/Main_Page)
|
- [Free Pascal Wiki](https://wiki.freepascal.org/Main_Page)
|
||||||
|
- [Basic Pascal Tutorial](https://wiki.freepascal.org/Basic_Pascal_Tutorial)
|
||||||
- *Why Pascal is Not My Favorite Programming Language* by Brian Kernighan, mostly of historic interest as almost all of the
|
- *Why Pascal is Not My Favorite Programming Language* by Brian Kernighan, mostly of historic interest as almost all of the
|
||||||
flaws described in the article has been fixed by modern Pascal compilers. <https://www.lysator.liu.se/c/bwk-on-pascal.html>
|
flaws described in the article has been fixed by modern Pascal compilers. <https://www.lysator.liu.se/c/bwk-on-pascal.html>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue