Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000544 [1003.1(2008)/Issue 7] Shell and Utilities Objection Enhancement Request 2012-02-18 19:12 2012-02-23 17:16
Reporter weeks View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Resolved  
Name Nathan Weeks
Organization Iowa State University HPC Group
User Reference
Section awk
Page Number 2441,2449
Line Number 77580-77583,77934
Interp Status ---
Final Accepted Text Note: 0001145
Summary 0000544: extend awk delete statement to delete entire array
Description The awk "delete" statement is currently defined as removing an individual array
element. To delete an entire array, a delete statement must be called for each
element of the array, typically in a loop.

At least gawk, mawk, BWK awk, Solaris /usr/xpg4/bin/awk, and BusyBox awk, which
collectively comprise the vast majority of installed awk implementations,
provide an extension that allows the deletion of all elements of an array with
a single delete statement, specifying only the array name without subscripts
(e.g., "delete ARRAY" instead of "for(i in ARRAY) delete ARRAY[i]")). Besides
the advantage of syntactic compactness, it allows an implementation to more
easily optimize the deletion of all array elements (e.g., the gawk manual states
"Using this version of the delete statement is about three times more efficient
than the equivalent loop that deletes each element one at a time.").

Desired Action Extend the awk syntax to allow
   delete ARRAY
where ARRAY is an array name.
Tags issue8
Attached Files

- Relationships

-  Notes
(0001136)
Don Cragun (manager)
2012-02-18 19:31

If this is done, the awk grammar needs to be fixed as well as the description of the delete statement in the Extended Description section.
(0001137)
waldner (reporter)
2012-02-18 23:34

The typical way to do that is split("", ARRAY).
(0001139)
weeks (reporter)
2012-02-19 19:03

That's a good point. If the standard isn't amended to accept "delete ARRAY", then it would be useful for it to mention the 'split("", ARRAY)' idiom as an efficient way to delete all elements of an array.
(0001145)
geoffclare (manager)
2012-02-23 17:15
edited on: 2012-02-23 17:28

On page 2441 line 77580 change:

The delete statement shall remove an individual array element. Thus,
the following code deletes an entire array:

for (index in array)
    delete array[index]
    
to:

The delete statement shall remove either a specified individual array
element or, if no element is specified, all array elements. Thus, the
following code:

for (index in array)
    delete array[index]

is equivalent to:

delete array

Both delete all elements of the array.

Add after page 2449 line 77934:

   | Delete NAME

Add after page 2463 line 78548:

Deleting all elements of an array one element at a time, via:
for (index in array)
    delete array[index]
is usually not efficient. This standard requires 'delete array' to
have the same effects, and this was supported in most implementations
as a more efficient operation. It is also possible to use
'split("", array)' to achieve the same effect and efficiency.


- Issue History
Date Modified Username Field Change
2012-02-18 19:12 weeks New Issue
2012-02-18 19:12 weeks Status New => Under Review
2012-02-18 19:12 weeks Assigned To => ajosey
2012-02-18 19:12 weeks Name => Nathan Weeks
2012-02-18 19:12 weeks Organization => Iowa State University HPC Group
2012-02-18 19:12 weeks Section => (section number or name, can be interface name)
2012-02-18 19:12 weeks Page Number => (page or range of pages)
2012-02-18 19:12 weeks Line Number => (Line or range of lines)
2012-02-18 19:12 weeks Issue Monitored: weeks
2012-02-18 19:31 Don Cragun Section (section number or name, can be interface name) => awk
2012-02-18 19:31 Don Cragun Page Number (page or range of pages) => 2441,2449
2012-02-18 19:31 Don Cragun Line Number (Line or range of lines) => 77580-77583,77934
2012-02-18 19:31 Don Cragun Interp Status => ---
2012-02-18 19:31 Don Cragun Note Added: 0001136
2012-02-18 23:34 waldner Note Added: 0001137
2012-02-19 19:03 weeks Note Added: 0001139
2012-02-23 17:15 geoffclare Note Added: 0001145
2012-02-23 17:16 geoffclare Final Accepted Text => Note: 0001145
2012-02-23 17:16 geoffclare Status Under Review => Resolved
2012-02-23 17:16 geoffclare Resolution Open => Accepted As Marked
2012-02-23 17:17 geoffclare Tag Attached: issue8
2012-02-23 17:28 eblake Note Edited: 0001145


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker