procedure Move(const source; var destination; count: sizeInt)
Move can be considered a very “low-level” routine.
It was originally developed to copy
char values within the same
string, but has ever since been (ab‑)used for other purposes, too:
- If Pascal’s strong data type system imposes (too many) restrictions that need to be circumvented for hardware-close programming and typecasting does not resolve the task’s problem or is too cumbersome.
- For circumventing Pascal’s restrictions in a very “hacky” nature: E. g. copying a
filevariable (there are good reasons you cannot simply
- For performance reasons: Copying huge blocks of memory with
movecould be faster than an equivalent
for‑loop. For instance the x86‑64 implementation takes advantage of architecture-specific circumstances.
A quick demo should not be missing.
Nevertheless, this example is bad in nature.
:= assignment would have been sufficient.
move possibly prevents the compiler from performing certain optimizations.
program moveDemo(input, output, stdErr); var x, y: integer; begin x := 42; move(x, y, sizeOf(x)); writeLn(y); end.