Open MrDurion opened 8 months ago
ADD
and SUBTRACT
can only work when all the arguments are "elementary" or all arguments are "composite". You can decide to display a warning or error when compiling/interpreting the cases marked with ??
in your question.PICTURE OF
instead of PICTURE IS
VALUE
clause which is one of the many clauses in COBOL that do not exist in BabyCobolADD A TO B
would be a good example of category 1. It would add C OF A
to C OF B
and leave D OF B
alone.ADD A TO Q
would be an example of category 2. Real COBOL compilers will refuse to compile it, complaining that Q
is "not a group name".ADD C OF A TO D OF B
would be an example of category 3. Should be obvious how that works.ADD Q TO A
would be an example of category 4. Again, real compilers stop on an error here.ADD A TO E
just takes two data structures and adds its corresponding constituents to each other. Since nothing name-matches within A
with anything within E
, this statement does nothing. You can opt for displaying a warning if this happens. Real COBOL compilers do not.
For the ADD and SUBTRACT statements, we are required to also add composite data, adding sub-elements if they have the same name. However, it is unclear what should happen when the sub-elements are different data structures.
We have 4 cases that can occur, and have assumed behavior for two of them, but we are unsure what should happen for the other two.
An example where this would occur:
How are we supposed to handle this?