Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.fortran Subject: fifo queue (was Data types _without_ pointers) Message-ID: <13711@mimsy.UUCP> Date: 23 Sep 88 16:33:24 GMT References: <1032@amelia.nas.nasa.gov> <4026@lanl.gov> <1038@amelia.nas.nasa.gov> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 33 In article <1038@amelia.nas.nasa.gov> fouts@lemming.nas.nasa.gov.nas.nasa.gov [is there an echo.echo here? :-) ] (Marty Fouts) writes: >... I can implement a fifo using an array and two integers .... [Fortran example deleted] >I can also do the same thing using pointers (from C): [C example also deleted; the C version was buggy] >Neither of these is a good substitute for (Not available in any >language I usually use) > >Declare fifo to be a fifo of real; > >and using 'fifo = x' to add x to the end of fifo and 'x = fifo' to >remove x from the begining of the fifo. You just need to use a *real* language :-) . There are languages that can do this, although you will usually have to define the implementation first (or borrow someone else's). C++ gets rather close. The syntax is a bit peculiar: you will have to write something like fifo(float) f; // uses a cpp macro hack to fake parameterised type f.put(x); // add x to tail x = f.get(); // get x from head The nice thing about the whole mess is that put and get can be expanded in-line (they are, after all, trivial operations). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris