Article View: comp.lang.misc
Article #5289Re: From Modula to Oberon
From: Lawrence Crowl
Date: Tue, 15 Mar 1988 21:05
Date: Tue, 15 Mar 1988 21:05
46 lines
2627 bytes
2627 bytes
In article <3764@bloom-beacon.MIT.EDU> peter@athena.mit.edu
(Peter J Desnoyers) writes:
)I wish they had put iterators in Ada. C provides a general linear iterator,
)but in CLU you can iterate through a tree or anything else. After all, the
)idea of iterating is so that you can separate the structure of bunch of data
)from the logic of:
)
) for each foo in bar
) do something
) end
In article <1130@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>When will people learn, data abstraction is not a programming language or type
>of programming language, it is a programming methodology.
>
>In particular if you want generalized iteration say in C, its a simple matter
>of defining an iteration function for that particular data type. Provide it a
>reset flag to start iteration, either a static var or extra field in the data
>type representing the current object and some termination object.
>
> for (object = iter_func(data_struct,START);
> object != TERMINATOR;
> object = iter_func(data_struct,NEXT)) {....}
>
>I do this for my generic hash tables in C when I need to dump the them in
>linear format.
Eddie Wyatt's proposal is not as general as CLU iterators. In particular, (as
Peter J Desnoyers points out) you can easily implement a tree traversal in CLU,
but you must allocate and maintain a stack of nodes in order to implement tree
traversal under the separate function scheme.
Another problem is that objects must have distinct TERMINATOR values. This is
not generally true.
The suggestion of using "either a static var or extra field in the data type"
fails when two iterations may proceed on the same structure at the same time.
(Note that this can happen without concurrency, but I admit it is rather rare.)
You can do all your data abstraction and programming in assembler. The issue
is what language constructs make such programming *effective*, not just
possible.
--
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:
<7747@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> <1130@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: <7747@sol.ARPA> Date: 15 Mar 88 21:05:45 GMT References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <3764@bloom-beacon.MIT.EDU> <1130@PT.CS.CMU.EDU> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 46