Xref: utzoo comp.lang.c:6090 comp.lang.misc:916 Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704A-Liber) Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: A bad design decision early on in A Message-ID: <3309@ihlpf.ATT.COM> Date: 9 Jan 88 00:17:13 GMT References: <1322@sugar.UUCP> <47000028@uxe.cso.uiuc.edu> <472@m10ux.UUCP> Reply-To: nevin1@ihlpf.UUCP (00704A-Liber,N.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 31 In article <472@m10ux.UUCP> rgr@m10ux.UUCP (Duke Robillard) writes: [some stuff deleted] > >But with a *real* implementation of data hiding, you wouldn't have to >go back through that long chain of garbage. To set some variable of >type foo, you'd call a function called set_foo. To print the time, >you'd call a routine called print_time_t. This is a major concept >behind "object oriented programming" languages, like smalltalk or (maybe) >C++. > (Please follow this up to comp.lang.misc) I really hated doing this back in the days when I programmed in Modula-2. I ended up having a lot of functions which did nothing but set and read variables. Unless you have a real smart optimizing compiler, using function calls instead of just referencing the variables has a large cost associated with it. (Yes, I know that in some situations you would rather have function calls because you can check for a legal value, valid range, etc., but that is another story.) Also, in order to use time_t (besides just printing it out), I do need to know what type it is. BTW, if you really need to do data hiding in C, you can use external static variables and write functions to access them (see K&R section 4.6). -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_