Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Rod Pemberton Newsgroups: comp.lang.forth Subject: Re: Data Stack of Just Pointers? Date: Fri, 18 Nov 2016 20:39:09 -0500 Organization: Aioe.org NNTP Server Lines: 28 Message-ID: <20161118203909.40027cd4@_> References: NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Claws Mail 3.13.1 (GTK+ 2.24.13; x86_64-unknown-linux-gnu) Xref: csiph.com comp.lang.forth:52725 On Fri, 18 Nov 2016 10:10:57 -0800 (PST) trans wrote: > Would a Forth implementation with a data stack that just contains > reference pointers have really bad performance? Each access of an item on the stack would have an extra pointer indirection. This isn't much time in and of itself, but since a Forth interpreter can execute millions of stack operations even for simple things, this will be slower. However, the slowness may still be within acceptable limits. This doesn't take into account the effect of processor caching, which is mentioned below. If the stack data can be of different sizes, your idea would eliminate the need for a linked list or stack frames or contiguous memory for the stack, but this offers no advantage in terms of executing fewer instructions. However, if the processor manages to store some of the pointer stack in the processor's cache, this could be significantly faster than linked lists or stack frames. Having data in cache may be fast enough that the slow-down from the extra pointer indirection is irrelevant too. If the stack data is of a consistent size, like for Forth, I see no point in using pointers. Rod Pemberton