In gforth, CREATE, by itself, creates a variable, which takes some memory space: a few bytes to store the value plus two instructions to put the address on the stack and return:
create a ok
42 a ! ok
a @ . 42 ok
If instead of a variable you want to create an 80-byte buffer, you can write
: TAMPON CREATE 80 ALLOT DOES> + ;
but those 80 bytes would come after the bytes taken by CREATE for the default variable, which is a waste.
Does CREATE waste space or am I missing something?
CREATEdoes not waste space. It "does not allocate data space in name's data field" (see 6.1.1000CREATE).This example shows incorrect usage:
At this moment,
aandherereturns the same address:So you have to reserve required space before use: