Deutsch English Français Italiano |
<b8e363fbdd6dbe028902981b0b336a0f@www.novabbs.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: mitchalsup@aol.com (MitchAlsup1) Newsgroups: comp.arch Subject: Re: Continuations Date: Mon, 15 Jul 2024 20:59:23 +0000 Organization: Rocksolid Light Message-ID: <b8e363fbdd6dbe028902981b0b336a0f@www.novabbs.org> References: <v6tbki$3g9rg$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="3410658"; mail-complaints-to="usenet@i2pn2.org"; posting-account="65wTazMNTleAJDh/pRqmKE7ADni/0wesT78+pyiDW8A"; User-Agent: Rocksolid Light X-Rslight-Posting-User: ac58ceb75ea22753186dae54d967fed894c3dce8 X-Rslight-Site: $2y$10$Hzs4xen2wZzFixCZyTrB0Ox53QyfmP.SfiYPEUUndgin3cgkEH0kW X-Spam-Checker-Version: SpamAssassin 4.0.0 Bytes: 3669 Lines: 63 On Sat, 13 Jul 2024 7:50:42 +0000, Lawrence D'Oliveiro wrote: > Has there ever been a hardware architecture that managed the flow of > control via “continuations”? I want to simply ask WHY ?? Why do you think this would add value to an ISA ?? Why do you think this would add value to an HLL ?? Why do you think this would add value to a programmer ?? > > That is, you do away with the hardware concept of a stack. Instead, you > have call frames that, while defined to some extent by the architecture, > can be located anywhere in memory (allocation managed by the OS, runtime > etc as part of the ABI). A call frame has a current program counter, and > maybe some other context like local variables and a static link for > lexical binding. Instead of a “return from subroutine” instruction, you > have a “load new call frame” instruction. You could learn to fly an airplane by coupling 16 or more electrodes to your head and practicing flying until your brain figured it out !! But there is a reason planes are not flow this way..... > > You might have a location defined in a call frame for a “pointer to > parent > call frame” field, in which case “return from subroutine” just loads > this > pointer into the current-call-frame register. But you could just as > easily > have pointers to other call frames defining other kinds of > interrelationships between them. And note that transferring to a > different > call frame does not automatically invalidate the previous one. If it > stays > valid, then there is no reason why you couldn’t, at some point, come > back > to it and resume execution from where it left off. Block structured languages allow for this, they are not "in that great a favor" right now. > > The beauty of continuations is that they are a single generalized > control > construct that can be used to implement specific language features like > regular routine calls, loops, exceptions and coroutines, all built from > the same common abstraction. One thing that is difficult to do with them > is arbitrary gotos. (I consider that a feature, not a bug.) The ugliness is (as BGB indicates) their poor performance. So, whatever they bring to the party, does not seem to be the "guest of honor". > > Very few high-level languages (outside of the Lisp family, anyway) seem > to > have implemented continuations as an explicit language concept. This is > an > integral part of Scheme, not so much it seems of non-Scheme Lisps. I > implemented it in my PostScript revival language > <https://bitbucket.org/ldo17/gxscript/>, and I am still trying to come > up > with a useful example, like for instance an implementation of > coroutines, > that doesn’t do my head in. ;)