Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #25466
| Date | 2013-08-29 19:55 +0100 |
|---|---|
| Subject | Re: Relocatable Blocks |
| From | Ian van Breda <igvb@btopenworld.com> |
| Newsgroups | comp.lang.forth |
| Message-ID | <CE4557B0.3ADC%igvb@btopenworld.com> (permalink) |
| References | <CE4017C0.3A79%igvb@btopenworld.com> <7xioytzdll.fsf@ruckus.brouhaha.com> |
Paul Rubin wrote on 25/08/2013 22:04: > > There doesn't seem to be a way specified to access data in a relocatable > block--are you saying the application should just treat hndl as > something like an indirect pointer that can change at any time? How is > that supposed to interact with multitasking? > > Do you really need dynamic resizing for Forth stacks? I thought very > deep stacks weren't really in the Forth spirit. In any case, since only > the top few stack elements are directly accessible, resize can be done > completely behind the scenes, by moving the deeper elements off to some > other place in memory, keeping the top elements at fixed addresses. The relocatable blocks are held in a 'heap', a more flexible form of storage mechanism than in a stack. Usually, each task may have its own heap, although that may not be necessary in a particular case. Typically it is used for storing data objects which have life-times that last longer than a stack, such as a word processing document or a stellar spectrum, which needs to be manipulated in various ways. During the progress of a program, many data objects may be allocated and freed and may be even resized. This may happen at any time and in any order, leaving gaps in the heap. The term 'handle' was used in both Mac OS, in its 'Classic' form, and in Windows. Control of the relocatable blocks was done behind the scenes, including moving that data internally, e.g. compacting a heap if it proves to be necessary to make space for new data. More recently, handles have been replaced by pointers but the idea is the same. See 'Crafting a Compiler', p.500-511, 2010, under 'Heap Management'. Albert van der Horst wrote on 26/08/2013 12:34: > This all seems pretty useless without words to > address into the blocks that are allocated. Point taken! Obviously you require things like H@ ( hndl offset -- x) and H! ( x hndl offset -- ) for extracting and storing values in a relocatable block, given a handle and an offset within a relocatable block. Also a definition like HDUMP ( handl start u -- ) which dumps part of a relocatable block, starting at a specified offset and given a number of bytes to be displayed. I use a Smalltalk-type Collection, which includes stacks, especially for the Forth dictionary headers. Data are placed in a stack frame for transferring to a relocatable block. Similarly, data can be extracted from a relocatable block and placed on the parameter stack in the form of a stack-frame for subsequent processing. Ian
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Relocatable Blocks Ian van Breda <igvb@btopenworld.com> - 2013-08-25 20:21 +0100
Re: Relocatable Blocks Paul Rubin <no.email@nospam.invalid> - 2013-08-25 14:04 -0700
Re: Relocatable Blocks Ian van Breda <igvb@btopenworld.com> - 2013-08-29 19:55 +0100
Re: Relocatable Blocks albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-08-26 11:34 +0000
Re: Relocatable Blocks Hans Bezemer <the.beez.speaks@gmail.com> - 2013-08-26 14:58 +0200
Re: Relocatable Blocks Hans Bezemer <the.beez.speaks@gmail.com> - 2013-08-26 15:30 +0200
Re: Relocatable Blocks anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-08-26 14:33 +0000
Re: Relocatable Blocks Ian van Breda <igvb@btopenworld.com> - 2013-08-29 20:22 +0100
Re: Relocatable Blocks Mark Wills <markrobertwills@yahoo.co.uk> - 2013-08-26 07:08 -0700
csiph-web