Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.lang.misc Subject: Re: From Modula to Oberon Message-ID: <1130@PT.CS.CMU.EDU> Date: 15 Mar 88 19:35:51 GMT References: <2827@enea.se> <1557@pasteur.Berkeley.Edu> <3764@bloom-beacon.MIT.EDU> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 32 > > 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 > ***This is not a flame against the author.*** 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 e-mail: edw@ius1.cs.cmu.edu