Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!mcsun!ukc!newcastle.ac.uk!turing!ncmh From: Chris.Holt@newcastle.ac.uk (Chris Holt) Newsgroups: comp.lang.eiffel Subject: Re: Functions without side effects (was Old confusion) Message-ID: <1991Jun14.180654.7113@newcastle.ac.uk> Date: 14 Jun 91 18:06:54 GMT References: <1991May30.141218.3446@mstr.hgc.edu> <130803@tut.cis.ohio-state.edu> <1991Jun7.135613.1515@mstr.hgc.edu> <1187@tetrauk.UUCP> Sender: news@newcastle.ac.uk Organization: University of Newcastle upon Tyne, UK, NE1 7RU Lines: 33 rick@tetrauk.UUCP (Rick Jones) writes: >In article kers@hplb.hpl.hp.com (Chris Dollin) writes: >> >> [doesn't see why "making a decision" would ever depend on the top >> element of a stack that wouldn't be popped] >> >>Perhaps we're talking about two different data-types both called ``Stack''? >While your vision of Stack corresponds to one particular implementation, common >in hardware, it's in fact quite a specific type of stack. There are many other >widely used types of stack where you do get at the top element without popping >it. Just to add another vision of Stack :-), mine has two operations Push : Stack x Value -> Stack Pop : Stack -> Stack x Value where calls are denoted via equations, and updates via 's (a clumsy syntax, admittedly). Then the usual procedural Push is S' = Push(S,v), the usual Pop might be (S',v) = Pop(S) with v not used again, Pop-Top is the same, with v used as the top value, and the Top function is (T',v) = Pop(S) with T not used again. The equations relating Push and Pop are then (S,v) = Pop(Push(S,v)) and S = Push(Pop(S)) where S != empty. I've always thought this was simpler... ----------------------------------------------------------------------------- Chris.Holt@newcastle.ac.uk Computing Lab, U of Newcastle upon Tyne, UK ----------------------------------------------------------------------------- "They have been at a great feast of languages, and stolen the scraps." - WS