Re: [stack] What are the advantages and disadvantages in manipulation of the return stack
<[email protected]> Mon, 14 Jun 2010 09:07:54 -0500
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 14 Jun 2010 09:10:53 -0000, "blazeski" <[email protected]> wrote: > So what are the upsides and downsides of allowing programmer > to manipulate the return stack? I'm unaware of any benefits in a language with higher order functions. You do need some sort of auxiliary stack in a first order language so that you can shove elements aside when necessary, but dip and friends eliminate the need for such a low level approach. Higher order functions also eliminate any of the control flow benefits you can derive from a manipulatable return stack. The obvious downside is that makes a mess out of the semantics of your language. You can no longer view functions as mapping a stack/queue pair to a new stack/queue pair. Instead, you now have to deal with an additional exposed implementation detail. Even if you specify exactly how the return stack is to behave (e.g. you disallow the compiler to inline functions), you'll still have eliminated essentially any possibility for equational reasoning because any function can rip its caller off of the return stack (or worse, if that's even possible). I think that allowing access to the to-be-evaluated syntax tree (i.e. the "queue") is also extremely harmful as it means any program modification has a global effect; you can't locally verify that some other part of the program doesn't behave differently depending on some part of the queue that you'll be changing. It would seem you're already far down this path however. - jn