On Wed, 7 Jan 2004, jattdemush wrote:
> Hi,
>
> i have a procedure with holds a variable i need in another
> procedure.
> How do i get that variable out without running the whole procedure??
A follow on from Chris Dollin's message. In the Pop11 primer
http://www.cs.bham.ac.uk/research/poplog/primer/START.html
Chapter 1 has an example worked out in some detail, the 'Rooms
database' example, which illustrates how a collection of basic
programming idioms can be expressed in pop11, including how to
define a procedure that produces a result that is used in another
procedure.
Chapters 3 and 4 have more examples explained in more detail.
If you have a copy of poplog you can get the same information
in Ved from this large file:
TEACH PRIMER
Also TEACH DEFINE provides similar information with slightly different
examples.
Remember that readline() -> list is a procedure that takes no arguments
and returns a list of words strings and numbers (possibly empty).
The expression 'readline' will not invoke the procedure. It will merely
produe the procedure as its 'result'. So
readline -> list;
will make 'list' another name for readline.
The use of 'readline' is illustrated in TEACH RESPOND, also available
here
http://www.cs.bham.ac.uk/research/poplog/teach/respond
As Chris said: if you don't want to produce buggy programs avoid
procedures that communicate via variables. Instead make them
communicate via inputs and outputs.
foo( baz(a, b, c), d, e )
runs the procedure baz, with inputs a, b, c, then foo with the result(s)
of baz plus the additional inputs d, e. The foo will leave its results
on the stack.
In pop11, that is equivlent to
a, b, c, .baz, d, e, .foo
Note that if baz uses only two inputs, then it will use b and c, and
leave a where it was.
If foo needs four inputs then it will get a. That is better expressed as
foo(a, baz(a, b, c), d, e)
All that illustrates that to use pop11 you have to understand how pop11
uses its 'open stack', which is both a source of great elegance and
power, and also a source of obscure bugs if you are not careful.
Aaron
|