Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: dror.openu@gmail.com Newsgroups: comp.compilers Subject: Re: Add nested-function support in a language the based on a stack-machine Date: Mon, 12 Feb 2018 14:16:20 -0800 (PST) Organization: Compilers Central Lines: 13 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <18-02-010@comp.compilers> References: <18-02-009@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="79235"; mail-complaints-to="abuse@iecc.com" Keywords: code, comment Posted-Date: 12 Feb 2018 17:29:32 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1951 > [This at least used to be a standard topic in compiler texts. You should > be able to do either in O(1). -John] I'm not sure how to calculate it in compile time, because the call frame doesn't have a fixed size, because I'm using the same stack for storing the call-frames and for the operations evaluation (iadd, isub, etc..). Maybe I should split it into two stacks, one for the call frames, and the second for the operation evaluations. I just sharing my thoughts. [I would think that your compiler should always know how many partial results are on the stack above the call frame so it should be able to use a fixed offset to get to the chain pointers at the base of call frame. -John]