Mitch.Bradley@ENG.SUN.COM (05/09/91)
I agree that the Forth model of memory allocation via HERE and ALLOT , and its association with the parameter field of CREATE ... DOES> words is fundamentally bogus. However, it is also fundamentally part of what we know as Forth. Nearly all Forth implementations use the HERE / ALLOT model of memory allocation. Consequently, I cannot imagine that the ANS Forth committee would see fit to change it. Furthermore, the committee is unlikely to approve at this time an extension word based upon the idea of a virtual dictionary, because few existing Forth systems (offhand, I can't think of any at all) have chosen to address that particular problem. However, the committee has provided an extension wordset for dynamic memory allocation, that can be used as the underlying memory acquisition mechanism for a relocatable heap. An implementation that wishes to make extensive use of such a heap could pre-allocate a modest-sized data space for use by ALLOT , and then recommend that CREATE .. DOES> words should use that data space sparingly. For example: : >DATA ( pfa -- addr ) @ ( handle) HANDLE>ADDRESS ; : MY-DEFINER \ name ( size -- ) ALLOCATE-HANDLE ( handle ) CREATE , DOES> >DATA ( ... whatever ) ; Mitch.Bradley@Eng.Sun.COM