ANSI C questions (parameters, structure assignment)

Esmond Pitt ejp at bohra.cpg.oz
Tue Sep 4 13:13:02 AEST 1990


In article <365 at saxony.pa.reuter.COM> dgil at pa.reuter.COM (Dave Gillett) writes:
> In <3636 at goanna.cs.rmit.oz.au> ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>
>>In article <360 at saxony.pa.reuter.COM>, dgil at pa.reuter.COM (Dave Gillett) writes:
>>> ... 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.
>
>>This is not a killer case at all.  It's a solved problem.  The very
>>same situation can occur in COBOL (look up "level 66 items").
>
> "A solved problem"?

In COBOL the "problem" is "solved" by the following two rules:

	1. For two items from two scopes to "correspond" they must have
	not only the same name but the same qualification within both
	scopes. E.g. a1.b.c and a2.b.c correspond, but a1.b.c and a2.c do not;
	nor do a1.b.c. and a2.b.z.c.

	2. If any target items overlap the results are undefined.
	
Whether this is considered to be a "solution" or indeed a "problem" is
up to the reader.

As for the implementation issues, implementing CORRESPONDING in a COBOL
compiler in compliance with the ANSI standard X3.23 takes about a page
of code, built around an algorithm to be found in Knuth volume I.

Is there any realistic alternative to rule #2?
-- 
Esmond Pitt, Computer Power Group
ejp at bohra.cpg.oz
D



More information about the Comp.lang.c mailing list