Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amelia!lemming.nas.nasa.gov!fouts From: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Newsgroups: comp.lang.fortran Subject: Re: data types without pointers Message-ID: <1058@amelia.nas.nasa.gov> Date: 24 Sep 88 15:45:53 GMT References: <4108@lanl.gov> Sender: news@amelia.nas.nasa.gov Reply-To: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Organization: NASA Ames Research Center Lines: 61 In article <4108@lanl.gov> jlg@lanl.gov (Jim Giles) writes: > >> [...] Try representing a dynamic length >> fifo using Hoare's structure and answering the questions: >> >> 1) What happens when I add to a fifo? >> 2) How do I represent this structure? >> 3) How do I keep track of the head/tail? >> 4) How do I detect an empty fifo? > >Fifo's _can_ be implemented as recursive data structures, but arrays >with indices are easier and more efficient. So I'll do that with a >Fortran 8x-like syntax. >[Fortran 8x-like syntax deleted] >Well, there you are. You even have the assignment operators you asked >for. There aren't any pointers here either. > Err, you didn't even try to answer my question. Your fortran 8x was just like my fortran, except that 8x allows you to keep the pieces together in a structure. I already showed how to do it with arrays. Any thoughts on the question I asked? >> BTW, recursive structures are a very clumsy way to think about bags, > >I agree. So don't implement them with recursive structures. Recursive >structures aren't for everything. Use the structure which best fits >the problem. This means: rarely use pointers - if you can avoid it. >And, if you're talking about language _design_, don't force pointers >onto your users. > OK. How do I implement bags. Certainly not with arrays. (;-) Best with linked lists. >[...] It is better to have different functionality actually have different >syntax as well. Most uses of pointers are actually something else >in disguise. And most other forms of other addressing are just uses of pointers in disguise. It is better to have different syntax for each notational way of thinking of the same functionality. I agree that generic C pointers, when thought of as memory references are a poor choice. I disagree that the model of pointers/pointer arithmetic as an alternative way of thinking about name space mapping to things like arrays and recursive structures is a problem. I find the semantics isomorphic and I find times when the syntax is a notational win -- for either arrays or pointers. > >J. Giles >Los Alamos +-+-+-+ I don't know who I am, why should you? +-+-+-+ | fouts@lemming.nas.nasa.gov | | ...!ames!orville!fouts | | Never attribute to malice what can be | +-+-+-+ explained by incompetence. +-+-+-+