A NOTE has been added to this issue. ====================================================================== http://austingroupbugs.net/view.php?id=1136 ====================================================================== Reported By: stephane Assigned To: ====================================================================== Project: 1003.1(2016)/Issue7+TC2 Issue ID: 1136 Category: Shell and Utilities Type: Omission Severity: Editorial Priority: normal Status: New Name: Stephane Chazelas Organization: User Reference: Section: awk Page Number: 2488-2489 Line Number: 80013-80018 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2017-04-19 20:56 UTC Last Modified: 2017-04-20 06:11 UTC ====================================================================== Summary: awk: missing case where a bare array name may be used ====================================================================== Relationships ID Summary ---------------------------------------------------------------------- related to 0000544 extend awk delete statement to delete e... ======================================================================
---------------------------------------------------------------------- (0003674) stephane (reporter) - 2017-04-20 06:11 http://austingroupbugs.net/view.php?id=1136#c3674 ---------------------------------------------------------------------- Re: note:3673 I understand the first item as one may declare and use functions that take array names as arguments (passed as reference). Apart from split(), no other builtin function specified in this standard accept bare arrays in any implementations I've tried (except for busybox awk where variables can be both scalar and array at the same time). Other builtin functions that awk implementations may provide as extension are out of the scope of this spec, and anyway this standard more or less precludes the addition of extra builtin functions as that would break compliance (prevent users from using them as user-defined functions, see how gawk disables all of it's extra functions under POSIXLY_CORRECT) About bug:544, that would mean a 4th item would need to be added here ("delete" would hardly be taken as a "function" as you typically call it without parenthesis). Also, I don't know about tawk where "delete array" apparently comes from but in gawk and busybox awk, the only implementations I know that also support it, the variable remains of array type after "delete variable", might be worth pointing out explicitly as one could assume that the variable is free to use as a scalar once it has been deleted. Last slightly related point, it may be worth clarifying how array parameters may be passed by reference to user-defined functions (and maybe split() as well). For instance, most awk implementations accept myfunction(foo, (myarray)), but not mawk: <pre> $ gawk 'function f(a) {a[1] = 1}; BEGIN{f((a)); print a[1]}' 1 $ nawk 'function f(a) {a[1] = 1}; BEGIN{f((a)); print a[1]}' 1 $ busybox awk 'function f(a) {a[1] = 1}; BEGIN{f((a)); print a[1]}' 1 $ mawk 'function f(a) {a[1] = 1}; BEGIN{f((a)); print a[1]}' mawk: line 1: type error in arg(1) in call to f mawk: line 1: illegal reference to variable a </pre> Issue History Date Modified Username Field Change ====================================================================== 2017-04-19 20:56 stephane New Issue 2017-04-19 20:56 stephane Name => Stephane Chazelas 2017-04-19 20:56 stephane Section => awk 2017-04-19 20:56 stephane Page Number => 2488-2489 2017-04-19 20:56 stephane Line Number => 80013-80018 2017-04-20 03:15 Don Cragun Note Added: 0003673 2017-04-20 03:16 Don Cragun Note Edited: 0003673 2017-04-20 03:17 Don Cragun Relationship added related to 0000544 2017-04-20 06:11 stephane Note Added: 0003674 ======================================================================