doc: add section on new/newOrNil/dispose
This commit is contained in:
parent
02765554fb
commit
f79d7d622a
1 changed files with 10 additions and 0 deletions
|
|
@ -103,6 +103,16 @@ Tridora-Pascal only supports the _break_ statement at the moment.
|
|||
The _exit_ statement can be used to exit the current procedure or function. If it is a function, the return value of the function is undefined if _exit_ is
|
||||
used before a return value is assigned.
|
||||
|
||||
|
||||
## Dynamic Memory Allocation
|
||||
Memory allocation generally works as expected with the *new* and *dispose* special procedures. The variant of *new* with two parameters that is specified in Wirth Pascal is not supported (partial allocation of a variant record). Instead, there is a variant of *new* that has a second parameter for allocating strings (see above).
|
||||
|
||||
If heap allocation fails, *new* does not return and instead causes a runtime error. To avoid this, a different special procedure called *newOrNil* can be used. This procedure sets the pointer
|
||||
variable to *niL* if heap allocation fails.
|
||||
|
||||
The function *MemAvail* returns the number of free bytes on the heap. It does not guarantee that this amount of memory can be allocated with *new*, because heap space can be fragmented.
|
||||
The function *MaxAvail*, which exists in some versions of Turbo Pascal and returns the size of the largest contiguous block of available heap memory, is not (yet) implemented.
|
||||
|
||||
## I/O
|
||||
I/O handling in Tridora Pascal is mostly compatible with other Pascal dialects when reading/writing simple variables from/to the console. There are big differences when opening/reading/writing files explicitly.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue