Re: Need some help understanding array definitions
- From: "Ed" <nospam@xxxxxxxxxxx>
- Date: Fri, 13 Jun 2008 22:06:21 +1000
"Elizabeth D Rather" <erather@xxxxxxxxx> wrote in message
news:qoednbsiAbDbVc3VnZ2dnUVZ_v_inZ2d@xxxxxxxxxxxxxxxx
Ed wrote:
"Elizabeth D Rather" <erather@xxxxxxxxx> wrote in message
news:88idnbPPNOfxr83VnZ2dnUVZ_gydnZ2d@xxxxxxxxxxxxxxxx
dkelvey@xxxxxxxxxxx wrote:
...
Marcel stated that it is not possible to create localYes, but these are definitely advanced strategies, and rarely
arrays but that is not true. With care, one can create
such arrays on the return stack or in an area of
memory allocated for such local arrays. One would
need to either have error checking or care when
using so as not to over use such space.
One could even setup a dynamicaly allocated spaces,
such as other languages do, with garbage collection and
such.
appropriate even then. The most advanced Forth programmers I know avoid
doing these things.
But what to do when they're not avoidable?
I can't answer that, as I have trouble imagining such a circumstance.
In Windows using the return stack for temps is, well, very
tempting. M/C programmers use this trick all the time.
Stephen wanted to extend locals to include buffers.
If I recall SwiftForth has words to allocate buffer space
on the return stack, using R@ to get the address.
User-variables (not standard) are fine but aren't dynamic.
There is ALLOCATE but it might be slow.
ALLOCATE is an ok way to get temporary buffer space. It isn't
particularly slow. Playing games with the Return Stack isn't portable,
and can present reliability issues. And in Windows, you certainly have
no limitations on static data space, why not use it?
Perhaps forth does need a return stack buffer allocation
word. The downside - slower than static buffers; care
must be taken to ensure the buffer is properly unwound;
max size is very system dependent; not so viable for
systems with small stacks. OTOH it should take less
effort to implement than a full blown locals scheme.
I'm just not at all persuaded that the need is there.
...
Presumably there is. Both major forth vendors have it in
their Windows product, albeit implemented in different ways.
Checkout R-ALLOC and R-BUF in SwiftForth.
.
- Follow-Ups:
- Re: Need some help understanding array definitions
- From: Elizabeth D Rather
- Re: Need some help understanding array definitions
- References:
- Need some help understanding array definitions
- From: xgeoff
- Re: Need some help understanding array definitions
- From: dkelvey@xxxxxxxxxxx
- Re: Need some help understanding array definitions
- From: Elizabeth D Rather
- Re: Need some help understanding array definitions
- From: Ed
- Re: Need some help understanding array definitions
- From: Elizabeth D Rather
- Need some help understanding array definitions
- Prev by Date: Re: Duff's device [Re: More fun with Miser's CASE]
- Next by Date: Re: Duff's device [Re: More fun with Miser's CASE]
- Previous by thread: Re: Need some help understanding array definitions
- Next by thread: Re: Need some help understanding array definitions
- Index(es):
Relevant Pages
|
Loading