Re: Function naming: Problems and proposed solution

On Sat, 2020-11-28 at 17:38 +0000, Michael Kay wrote:
> Let's think about map:remove(). Is there any way we can make it work
> without a prefix, given that fn:remove#2 also exists, and is also
> applicable to maps (though it doesn't do anything useful with them).
> We have the problem that $map => remove(1) already has a well-defined
> meaning (it returns an empty sequence).

remove($from, $itemlist)

  If $from is a map, returns a map whose keys do not include any items
in $itemlist.

  If $from is an array, returns a potentually shorter array with any
items at the positions in $itemlist removed

  Otherwise,
  returns, if $itemList treat as xs:integer, returns $item without any
item whose position() is greater than or equal to itemlist.

But this is ugly and may break existing code that was supplying e.g. a
sequence of arrays & sometimes only one array in the sequence.

So, we could add fn:without() designed to work that way, and deprecate
remove(), maybe?

Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

Received on Saturday, 28 November 2020 23:25:28 UTC