On the whole I agree, and I respect the current status quo of the specification. However, I expect more changes will follow from actually working with it. IMHO the current distinction between sequences and arrays could eventually be abolished.
2015-06-26 16:21 GMT+02:00 Michael Kay <[email protected]>: > > > Agreed, it could be implemented as a user-defined function (although this > particular solution currently throws an error in eXist). However, what > bothers me is that fn:index-of(1,2,[3,4], 3) may lead to unexpected > results, because the array is flattened. I get the impression that > array-specific semantics are sacrificed here, where in other cases they > aren't, and the dividing line is still unclear me. > > > Arrays will give unexpected results, full stop. We spent two years trying > to find a design that didn’t have unexpected results, and we failed. Start > with the fact that $A[1] returns the whole array, and that you can’t > iterate over arrays with FLWOR expressions. Arrays are grafted on to the > data model as an afterthought, and it shows right through. That’s not for > want of trying: we were running out of names for all the different ideas we > rejected as unworkable. > > The choice of functions in the library is inevitably arbitrary. I think we > found that if you wanted a completely minimalist approach, everything could > be defined in terms of three functions. At the other extreme you would have > the functx approach, a thousand functions to do everything you could ever > imagine, but where it’s quicker to write the function yourself than to find > it in the library. > > Michael Kay > Saxonica > > > Thanks, > Wouter > > 2015-06-26 14:16 GMT+02:00 Michael Kay <[email protected]>: > >> I would think both of these could be implemented as user-defined >> functions but it’s hard to know without seeing a specification: saying you >> want a function called array:index-of() is not very informative unless you >> explain exactly what you want the function to do. >> >> If it’s to behave like fn:index-of() then you can write it as >> >> array:index-of($array, $value) { >> (1 to array:size($array))[ $array(.) = $value ] >> } >> >> which is hardly a great hardship to write as a user-defined function. >> >> >> Michael Kay >> Saxonica >> >> On 26 Jun 2015, at 12:18, W.S. Hager <[email protected]> wrote: >> >> Hello, >> >> I've been working with the recent xquery 3.1 implementation in the >> develop branch eXist-db. I encountered some cases that were quite hard to >> work around: >> >> - the lack of array:index-of() >> - the lack of the iterator index in arrayfor-each and related >> higher-order functions >> >> Perhaps someone of the workgroup is available to discuss those cases. >> >> Thanks, >> Wouter >> -- >> >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> >> >> -- >> >> W.S. Hager >> Lagua Web Solutions >> http://lagua.nl >> >> _______________________________________________ >> [email protected] >> http://x-query.com/mailman/listinfo/talk >> >> >> > > > -- > > W.S. Hager > Lagua Web Solutions > http://lagua.nl > > > -- W.S. Hager Lagua Web Solutions http://lagua.nl
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
