Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt.cs.cmu.edu!gnome.cs.cmu.edu!hugo From: hugo@gnome.cs.cmu.edu (Peter Su) Newsgroups: comp.sys.amiga Subject: Re: Modula and C Message-ID: <23@gnome.cs.cmu.edu> Date: Tue, 21-Apr-87 10:39:48 EST Article-I.D.: gnome.23 Posted: Tue Apr 21 10:39:48 1987 Date-Received: Wed, 22-Apr-87 03:18:31 EST References: <680@puff.WISC.EDU> Distribution: comp Organization: Carnegie-Mellon University, CS/RI Lines: 78 >> 2) Dynamic data structure extension isn't transparent. > >Non comprende, explain please? Well, in other languages like CLU and LISP, the compiler/interpreter/runtime has some smarts and will garbage collect storage that you aren't using anymore for you. Thus, you don't have to worry about it. You allocate the storage you need, use it, and then when you don't use it anymore, LISP just grabs it back. BASIC in fact, usually does this with string storage... >> 3) Functions are second-class citizens. >Again, I don't know what you are talking about. Please describe rather >than generalizing. >> 4) Types are (at best) third-class citizens. >See above. >> 5) The languages aren't self-extensible. >> >What do you mean by "self-extensible"? I have built up quite a library of >higher level routines, organized into modules. Clearly this isn't what >you are talking about. What is? > While it is true that you can build nice libraries and such in C or MODULA, again, other languages have better support for this. I think the three points made above are complaining about the fact that extensions that you put into the language have a different syntactic structure than facilities that are already in the language. For example, if you add a complex number type to C, then you can't use "+" to add complex numbers, you have to use say, "cadd()" instead. In this way, C isn't self extensible and you can think of C functions as being "second-class". On the other hand, in C++, you can add a complex kind of "+" operator, and it's operation is from then on, totally transparent. You just say "foo+bar" like you always have. LISP and FORTH are also like this, in that the syntax used for lanugage extensions is the same as that used for the core language. Add a function to lisp, and you call it just like you call all the other lisp function that you have. Now, when we really get fancy, there are the languages like CLU, ADA (yuck) and Smalltalk, oh yeah, C++ too, where not only can you extend the operators of the language, but also its basic data types. That is, you can define a data structure, and the operations that can be performed on that data structure, and incorporate you new type into the language in a very easy way. Not only that, but from then on, when you use the type, the idea is that you would only access the structure with the operations that you have specified, and the language *enforces* this. Thus, when you define a complex number type in CLU, and say, operations to get the real and imaginary part, the person outside the module can only ever get the real and imaginary part using the functions you have given him. The big deal is, that you can change the representation of the type arbitrarily, and as long as the operations you give out still work, no code breaks. Note that Pascal and C, and Modula really don't let you do this very easily. No matter what you do, whoever is using you library can always bypass your interfaces and look directly at the bytes of the data structure, and this causes bugs, and all sorts of nasty things. This idea of "abstract data types" has been floating around a long time, but no one really seems to pay much attention to it in practice. We all just keep hacking in the mucky waters of C... Oh well, Cheers, Pete -- ARPA: hugo@cmu-cs-gandalf.arpa BELL:412-681-7431 UUCP: ...!{ucbvax,ihnp4,cmucspt}!hugo@cmu-cs-gandalf.arpa USPS: 5170 Beeler St., Pittsburgh PA 15213 QUOT: "What's that I smell? I smell home cooking. It's only the river!" _ Talking Heads -- ARPA: hugo@cmu-cs-gandalf.arpa BELL:412-681-7431 UUCP: ...!{ucbvax,ihnp4,cmucspt}!hugo@cmu-cs-gandalf.arpa USPS: 5170 Beeler St., Pittsburgh PA 15213 QUOT: "What's that I smell? I smell home cooking. It's only the river!" _ Talking Heads