Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretation for IEEE Std 1003.2™-1992 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)--Part 2: Shell and Utilities

Copyright © 1996 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.

Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.

IEEE Standards Department Copyrights and Permissions 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA

Interpretation Request #101
Topic: Array parameters in bc? Relevant Clauses:,

In subclause, the grammar for bc, lines 1635 - 1637 are:

parameter_list : LETTER
| define_list ',' LETTER
;Where define_list is defined in 1642 - 1646 as:
define_list : LETTER | LETTER '[' ']'
| define_list ',' LETTER
| define_list ',' LETTER '[' ']'

First, I thought 1003.2-1992 4.3 (bc) did not intend to include array parameters. The above grammar allows array parameters for ALL except the LAST parameter. This is rather strange if array parameters were to be included in the language.

Here is what I would like to know:

A) Is line 1636 wrong and should be | parameter_list ',' LETTER (What I thought it should ... not allow array parameters.) OR
B) Does the standard support array parameters and line 1633 would need to be changed to allow arrays for *ALL* parameter locations. The change would make 1633 read: | define_list (It currently reads "| parameter_list" AND such a change would then mean no rule uses the "parameter_list" productions so lines 1635 - 1637 should be removed.)

MY interpretation would be option A from above. Now to muddy the waters.... in (Extended Description) lines 1389 - 1391 state: "A whole array passed as an argument shall be specified by the array name followed by empty square brackets." This is not supported by the grammar! (Lines 1662, 1647-1652 (and 1659-1680)) (If you agree with me that A from above is correct, then the lines 1398 - 1391 should be deleted about passing an array.)

Finally, it does appear that IF arrays are allowed as parameters (which I presumed the standard didn't allow) then they must be "call by value" arrays. From line 1391 "All function arguments shall be passed by value." What is required of a conforming processor?

Interpretation Response #101
According to historic practice on BSD and System V systems, array parameters were allowed, just not as the last parameter for arguments. This does not prevent implementations from allowing array parameters to be accepted as the last argument. Lines 1628-1646 on page 202 properly define function declarations as per historic practice.

As specified by the standard line 1391 page 196, function arguments are "call by value". The grammer allow functions to be defined taking array parameters except for the last parameter. This matches historic practice. The grammer however does not allow array arguments to be passed to functions when they are invoked. This seems to be a defect. The standard states the behavior for function declarations for the bc cmd, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale for Interpretation