Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!iitmax!gkt From: gkt@iitmax.iit.edu (George Thiruvathukal) Newsgroups: comp.lang.modula2 Subject: Re: POINTER/LINKED LIST HELP? Message-ID: <1991Apr8.225822.11622@iitmax.iit.edu> Date: 8 Apr 91 22:58:22 GMT References: <10726.27FA98F3@urchin.fidonet.org> Organization: Illinois Institute of Technology / Academic Computing Center Lines: 30 In article <10726.27FA98F3@urchin.fidonet.org>, Rajah.Dodger@urchin.fidonet.org (Rajah Dodger) writes: > I may be naive here (I haven't done any serious programming in three > years) but I see no reason why you couldn't have a "generic pointer". You are correct. Modula-2, as defined in Programming in Modula-2, has two data types which are "generic" in nature: WORD and ADDRESS. These types are defined in the SYSTEM module. > What you would need to do would be to make it a pointer to some > (arbitrarily chosen) data type that is large enough to hold the largest > item your programs would want to point to. Then you dereference and do a > type cast. I can see a few problems with this, but it looks like a > reasonable start. Actually, you have a good handle on the concepts. The generic pointer (of type ADDRESS) is a pointer which can hold any pointer type. It cannot be dereferenced, however, because it is unknown at compile time what the generic pointer points to. In short, to actually examine what is pointed to by a variable of type ADDRESS, one must assign the variable to a pointer to a specific type and dereference that pointer. You might want to contrast this with the mechanism employed in the C language, where a "cast operator" is present for the purpose of explicitly changing the type of the pointer, even if it is generic, into another pointer type. -- George Thiruvathukal Laboratory for Parallel Computing and Languages Illinois Institute of Technology Chicago