6.2.2395 UNUSED CORE EXT

( -- u )

u is the amount of space remaining in the region addressed by HERE, in address units.

ContributeContributions

EricBlakeavatar of EricBlake [383] What should the behavior be if the system has no hard-coded limit on size?Request for clarification2025-07-19 01:57:17

On a system where the data space grows dynamically, there is no inherent compile-time limit on the maximum address in data space, and there might be no easy way to probe at runtime how large of an address can be allocated without failure. In that scenario, is it better to include the word UNUSED and have it return -1 to indicate unknown (or rather, the maximum unsigned integer since the prototype uses 'u'), or to omit the word UNUSED from the core extension set? Some traditional systems had MORECORE for adding more storage to the data space when UNUSED indicated that the current space was insufficient, but MORECORE is not standardized.

AntonErtlavatar of AntonErtl

If you include unused, it has to provide the size of the remaining dictionary (here region) space. Returning the maxiumum unsigned value (what -1 becomes if you interpret it as unsigned) is probably wrong: unused allot should work.

Letting unused report less than might actually be allotable is not according to the specification, either, but I don't see how a standard program that uses unused would run into problems from that. At worst it uses less memory than would otherwise be available.

Finally, not implementing unused avoids the problem completely, but programs that use unused will not work out of the box. I don't think there are many such programs, however.

Closed
Reply New Version