Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!uw-beaver!zephyr.ens.tek.com!tektronix!percy!m2xenix!puddle!p25.f506.n106.z1.fidonet.org!Jon.Guthrie From: Jon.Guthrie@p25.f506.n106.z1.fidonet.org (Jon Guthrie) Newsgroups: comp.lang.modula2 Subject: Re: Procedure Variables and Records and Sorting Message-ID: <3139.27EBB45D@puddle.fidonet.org> Date: 22 Mar 91 02:15:25 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 1:106/506.25 - Fulcrum's Edge, Spring TX Lines: 26 On a message of 19-Mar-91, George Emery (1:105/6.0) Said: > Making use of procedure variables to set the sort method is old hat to > most folks. What I'm trying to figure (can it even be done?) is a way > to allow a procedure to sort different types of records. In C, this sort of thing is a piece of cake because of the looser typing. Unfortunately, there's no way to define the type of an array argument at runtime. So, unless you're willing to put up with a hideously ugly kludge, there's no way to write a general array sort in Modula-2. However... It IS possible to write a generic linked-list sorting routine in M-2. I, and others, have done so in C and I'm willing to convert the C code that I have into M-2. Of course, none of this does you the slightest bit of good if you don't want to sort linked lists. (You don't say what you want to sort, but most people prefer to deal with arrays.) -- uucp: uunet!m2xenix!puddle!106!506.25!Jon.Guthrie Internet: Jon.Guthrie@p25.f506.n106.z1.fidonet.org