home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!goanna!ok
- From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
- Newsgroups: comp.lang.c
- Subject: Re: Write a structure?
- Message-ID: <15863@goanna.cs.rmit.oz.au>
- Date: 9 Nov 92 04:22:47 GMT
- References: <1c0umfINNell@sgi2.mathstat.uoguelph.ca> <15597@goanna.cs.rmit.oz.au> <531@ulogic.UUCP>
- Organization: Comp Sci, RMIT, Melbourne, Australia
- Lines: 28
-
- In article <531@ulogic.UUCP>, hartman@ulogic.UUCP (Richard M. Hartman) writes:
- > The problem is not that you cannot write pointer, but that it
- > does you no good.
-
- There are two problems. One is that it doesn't do you any good to write
- pointers (people keep telling me that it _is_ useful but nobody has sent
- me as much as one line of code from a working program that does it).
- The other is that the compiler has enough information to _tell_ that it
- won't do you any good, but because of the cast to void* is required to
- forget that, shut up, and do it anyway.
-
- > It is usually good form to write a routine that writes a structure
- > that "knows" which fields are actually pointers that need to
- > be dereferenced:
-
- Agreed. I even provided the students in question with sample code to do
- this. It helped that I had used Sun's XDR. But that approach only works
- when the data structure being written is a tree. If you have N records
- pointing to the same dynamically allocated string, you get N copies of the
- string when you read them back.
-
- > When you point out to a beginner what the problem is, and explain
- > something like what I have outlined here the problem goes away.
- > That what "beginners" are there for, to learn about the nasty stuff.
-
- Gosh, you must deal with some wonderful beginners. Tell them about a
- mistake and they never make it again. Re-read Donald Knuth's remark on
- his bug-log for TeX.
-