Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: John Levine Newsgroups: comp.compilers Subject: Re: Add nested-function support in a language the based on a stack-machine Date: Tue, 6 Mar 2018 04:31:01 -0000 (UTC) Organization: Taughannock Networks Lines: 27 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <18-03-024@comp.compilers> References: <18-02-009@comp.compilers> <18-03-002@comp.compilers> <18-03-012@comp.compilers> <18-03-020@comp.compilers> Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="73676"; mail-complaints-to="abuse@iecc.com" Keywords: code, Pascal Posted-Date: 06 Mar 2018 00:24:45 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Cleverness: some Xref: csiph.com comp.compilers:1978 >>>>This is because displays were found to be more costly for Algol-like >>>>languages ... >> >>>> IIRC the additional cost is in updating the display on calls >>>>and returns. I get the impression that displays describe two different things. One is a static array that has one entry for each level of lexical scoping. In a routine declared N levels (zero based) down, its prolog saves the Nth entry in the display and replaces it with a pointer to the current stack frame, and the epilog restores it. It can assume that higher level routines have correctly set entries 0:N-1. That seems pretty efficient. Assuming the saved pointer is at a known location in each stack frame you can do a longjmp and unwind stacks without too much pain. The other is the same array, but with a copy of the current display in each routine's stack frame. This is slower at call time but probably faster to use on machines like S/360 without direct addressing since the display on the stack is addressable from the frame pointer, but static data needs to load a pointer from a constant pool. A longjmp doesn't need anything special since stacked displays go away when the stack frames go away. R's, John