Path: utzoo!attcan!uunet!saxony!dgil From: dgil@pa.reuter.COM (Dave Gillett) Newsgroups: comp.lang.c Subject: Re: ANSI C questions (parameters, structure assignment) Message-ID: <360@saxony.pa.reuter.COM> Date: 28 Aug 90 09:00:43 GMT References: <1081.26d26274@desire.wright.edu> <352@saxony.pa.reuter.COM> <3615@goanna.cs.rmit.oz.au> Organization: Reuter:file Inc (A Reuter Company) Palo Alto, CA Lines: 47 In <3615@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: >In article <352@saxony.pa.reuter.COM>, dgil@pa.reuter.COM (Dave Gillett) writes: >: In <1081.26d26274@desire.wright.edu> demon@desire.wright.edu writes: >: >struct_thing -= still_more_struct; >: >struct_thing *= even_more_struct; >: >: Recall that "x -= y" is equivalent to "x = x - y". Will your VAX C let >: you get away with "struct_thing = struct_thing - still_more_struct"? How >: have you declared "struct_thing" that lets it both (a) be a structure, and >: (b) be in the domain of subtraction, which normally works on *numbers*??? >Let that stand as typical of the answers. >I'd like to point out that given > struct SomeTag this, that; >statements like > this += that, this -= that, this *= that >and so on are perfectly reasonable things to do as such. In COBOL, > ADD CORRESPONDING THIS TO THAT. > SUBTRACT CORRESPONDING THIS FROM THAT. >As it happens, this facility is not present in C. There is nothing in >the language which would make it especially difficult to implement, it's >just that nobody ever thought it worth while. It was a sensible question. You've suggested a possible semantics for "this -= that" and its ilk. First of all, it's not obvious to me that this is the semantics that "demon" had in mind--so the conclusion that the original question was reasonable can hardly be based on this! You'll notice, at the end of the passage quoted from my post, I wonder what kind of semantics were intended. But secondly, we have the assertion that "there is nothing in the language which would make it especially difficult to implement", and I'm not sure that's true at all. I can envision a number of scenarios where it would have to be extremely awkward, some cases where a diagnostic message should be issued but it could be extremely diifficult to pinpoint the error being diagnosed, and at least one killer case: where two names appear in a union in the destination struct but as separate components of the source struct. The result should store two different values into a single location. C is a structured language. COBOL is not. The distinction is *not* moot. "CORRESPONDING" is a powerful feature, and its implementation cost is, I'm sure. much higher than you think--and places non-trivial demands on the data declaration portions of the language. I'm pretty certain that trying to add this feature to C would be a monumental mistake. Dave