WG15 Defect Report Ref: 9945-2-140
Topic: awk - reevaluation of field varibles


This is an approved interpretation of 9945-2:1993.

.

Last update: 1997-05-20


								9945-2-140

 _____________________________________________________________________________

	Topic:                  awk - reevaluation of field varibles
	Relevant Sections:      4.1.2

Defect Report:
-----------------------
From: mark@mks.com (Mark Funkenhauser)
Date: Fri, 15 Sep 1995 17:28:47 -0400 (EDT)


Dear Standards Board,

    I would like to an request official, binding interpretation
    from WG15 concerning the following point in ISO/IEC
    9945-2:1993 (POSIX.2).

    In Section 4.1.2 it says:
	The symbol $0 shall refer to the entire record;
	setting any other field shall cause the reevaluation of $0.
     and
	Assigning $0 shall reset the value of all other fields and the NF
	built-in variable.

    The questions are:
      1) how exactly is $0 to be re-evaluated?
         Should it be using the current value of OFS?

	 Note: This is how its historically been documented on page 36
	    in The AWK Programming Language (1988) 
	    by Aho, Kernighan and Weinberger.
	    Also, section 4.1.7.3 (line 314-317) implies this behaviour 
	    since this is what is done when an assignment is made 
	    to a non-existent field.

      2) (a)When $0 is assigned to, how exactly should the other fields
	 be reset? (b)What does "reset" mean exactly?

	 Note: Historical documentation (The AWK Programming Language)
	       says that "when $0 is changed by assignment or
	       substitution, $1, $2, etc., and the NF will be recomputed"

	 (c) Is there a reason why POSIX.2 is not more specific on how
	 these fields should be reset?
         (d) Is it reasonable to assume that the fields shall be computed
	 from the new $0 using FS?
	 (e)If so, then should this FS be the current value 
	 (at time $0 was assignment) or should it be the value that 
	 was current when the last record was read?
	 (See somewhat related 9945-2 interp. request #118 and #80)


    Thank you for your attention to this matter.

    Mark Funkenhauser


Interpretation response
------------------------


Q.1: The standard states on page 163, section 4.1.2 (last paragraph),
that $0 is re-evaluated if any field is set. Page 171, section 4.1.7.3 third 
paragraph,  indicates that assignments to non-existent
fields cause the value of $0 to be recomputed with the fields
seperated by the value of OFS

Since "recomputed" and "re-evaluated" are neither one clearly defined, then
the standard is unclear in what it means for $0 to be re-evaluated, and
no conformance distinction can be made between alternative implementations
based on this.  However, it is clear that the current value of OFS
should be used whenever $0 is re-computed.  When $0 is re-evaluated 
it is unclear if OFS or FS is used.


Q.2: (a)The standard is unclear on this issue, it states that they
are "reset" but does not define what reset means.

(b)The standard does not specify what "reset" means.

(c)The interpretations committee believes that the authors of the standard did
not realise these ambiguities were present in the specification.

(d)Yes, although the standard is unclear on this issue,
we believe using the value of FS while resetting the values of
fields when $0 is reassigned is consistent with the standard.

(e)The standard does not speak to this issue, and as such no
conformance distinction can be made between alternative implementations
based on this.

These issues are being forwarded to the sponsor.

Rationale
-------------
None.
Forwarded to Interpretations group: Sep 22 1995
Recirculated for 30 day review: Oct 23 1995
Finalised: Nov 29 1995