This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29685 - [FO31] array:put()
Summary: [FO31] array:put()
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2016-06-04 13:11 UTC by Michael Kay
Modified: 2016-07-21 13:53 UTC (History)
1 user (show)

See Also:


Description Michael Kay 2016-06-04 13:11:46 UTC
I do know that we are past the point of adding new functions because they are a good idea, but in writing an application to make use of arrays recently, I found the absence of array:put() really painful. That is:

array:put($array, $index, $value)

which returns

$array => array:remove($index) => array:insert-before($index, $value)

that is, it replaces the value at position $index with a new value.

This seems such a basic omission that I wonder if we should consider it even at this late stage.
Comment 1 Michael Kay 2016-06-07 17:00:35 UTC
The WG agreed to add this function.

Test cases have been committed.
Comment 2 Michael Kay 2016-06-07 17:16:27 UTC
The function has been added to the spec.
Comment 3 Josh Spiegel 2016-06-08 15:19:02 UTC
I don't see it yet, but can you please use the same signature as insert-before?  e.g.

array:put($array as array(*), $position as xs:integer, $member as item()*) as array(*)

i.e. position and member instead of index and value.