Path: utzoo!attcan!uunet!lll-winken!ames!xanth!ukma!uflorida!novavax!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.sources.d Subject: Re: Comments on INSERT.c Message-ID: <332@twwells.uucp> Date: 16 Jan 89 00:20:53 GMT References: <308@twwells.uucp> <313@twwells.uucp> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 60 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article webber@porthos.rutgers.edu (Bob Webber) writes: : It turns out that the man page on open does claim to start the file : pointer at the beginning. As far as I am concerned, the lseek is the : equiv of initializing in the program text something that is already : implicitly properly initialized. With one difference: the unnecessary initialization of data (usually) does not have a cost. The lseek's do. : I see no reason to prefer the fopen(3) based routines over the open(2) : based routines. Certainly the open(2) routines were quite adequate to : the task at hand. Portability. They are specific to Unix. : Although a few people have mentioned to me that I could have written : 0L instead (long) 0; no one has been able to show me why I should : prefer to. This seems purely a matter of personal style (and naturally : I prefer my own way of doing things which is why I do them that way). Consider: a complex construct is more difficult to understand than a simple one. 0L is a single token, and is understood to be one. (long)0 is an expression, which requires some level of interpretation. Even though this is a trivial case, consistent application of the implied principle creates better understandable code. : At the time I wrote the program, I only accessed BSD man pages and so : was not aware that non-BSD systems lacked ftruncate (a function which : really should be added to any system that has to contend with tight : disk space). Besides mentioning the use of ftruncate, the 2nd version : did mention that this was BSD dependent. People who want to run INSERT : are strongly urged to get a BSD-based UNIX system. :-) But seriously, I do wish BSD was available on a machine I can afford. : The main motivation for the coding style was to make sure all errors : were covered, so that the program wouldn't fail without the user knowing : that it had. Lord knows that there are plenty of programs out there : with pretty error messages that ignore many system error returns. : The fact that the program cannot be conveniently used without easy : access to its source seems to me a benefit rather than a drawback. I'm not going to argue that point, not here; but let me suggest that you are in a distinct minority. Most people consider having to go to the source to understand a program to be either a failure to generate good error messages or bad documentation, or both. : If someone else wants to write a version by their own lights, I have : but one word of advice: read carefully the man pages of all system : routines used and test the program out on a file system that is 105% : full -- pretty user interfaces on broken programs are of no use to : anyone. Amen. --- Bill { uunet!proxftl | novavax } !twwells!bill