Article View: comp.lang.misc
Article #5299Re: From Modula to Oberon
From: Lawrence Crowl
Date: Wed, 16 Mar 1988 19:22
Date: Wed, 16 Mar 1988 19:22
33 lines
2427 bytes
2427 bytes
In article <1139@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
]The debate about CLU iterators misses an important point: CLU iterators are
]coroutines, which C does not have. The implication is that per-iteration
]state is nicely hidden in CLU ("on the stack" in the coroutine local
]variables), and has to be explicitly managed in C (or any other coroutine-free
]language) by putting the state into globals or making the user hang on to the
]state.
In article <22162@bbn.COM> schooler@oak.bbn.com (Richard Schooler) writes:
>But do you need coroutines to implimented generalized iteration? I think not.
>The optional solution I posted should allow you to perform the same task.
The CLU iterators are not general coroutines, but a special case that allows
them to be implemented with the conventional activation stack. The use of
iterators reduces programmer effort. It does not make something possible that
was not previous possible.
>The optional solution was to provide the iteration function a function to
>invoke on each member of the enumerated list. A single call would be made to
>iterate through the list. ... [inorder tree traversal example deleted] ...
>I do see one problem though, which is dealing with variable referenced inside
>the loop. They would have to become global. Comments as to why this method
>might not work in general?
The method can work in general. In fact, it is very powerful in general.
However, it requires nested functions so that the loop-body-function can gain
access to the local variables of the code wanting the loop. This only becomes
convenient when the language allows inline function defininition (something
like BCPL's value-yielding blocks).
--
Lawrence Crowl 716-275-9499 University of Rochester
crowl@cs.rochester.edu Computer Science Department
...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627
Technical Details
Message-ID:
<7781@sol.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!crowlReferences:
<2827@enea.se> <1557@pasteur.Berkeley.Edu> <3764@bloom-beacon.MIT.EDU> <22162@bbn.COM> <1139@PT.CS.CMU.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!crowl From: crowl@cs.rochester.edu (Lawrence Crowl) Newsgroups: comp.lang.misc Subject: Re: From Modula to Oberon Message-ID: <7781@sol.ARPA> Date: 16 Mar 88 19:22:37 GMT References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <3764@bloom-beacon.MIT.EDU> <22162@bbn.COM> <1139@PT.CS.CMU.EDU> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 33