Re: Range Expressions

I showed the proposed syntax (1 to 5 by -1) to a non-X(Path|SLT|Query)
developer, and the immediate response was:

  You must be wrong, it’s surely supposed to be: 5 to 1 by -1

I guess it’s too late to always start counting with the smaller value,
or to even allow "5 to 1" for reverse counts. Michael initially
proposed to place "by" ahead of "to" [1]…

  5 by -1 to 1

…and I wonder if it’s not the better choice?

[1] https://github.com/expath/xpath-ng/issues/22
____________________________________

On Tue, Dec 1, 2020 at 10:02 PM Dimitre Novatchev <dnovatchev@gmail.com> wrote:
>
> > Apart from anything else, it loses the idioms in the current language that rely on a range being a sequence of integers,
> > enabling familiar constructs such as x[position() = 1 to 10].
>
> Well, there is nothing wrong with series of time periods in a total time range.
>
> Maybe we can have a lifted overload of range, providing a function that, when applied on the provided as integers start, end and step, will produce the actual start, end and step for the actual range:
>
> range($startBase as xs:integer,
>       $endBase as xs:integer,
>       $stepBase as xs:integer,
>       $provider as function(xs:integer) as item() )
>    as item()*
>
> So, the provider() or better name, will convert the integers to whatever  typed-data we need.
>
> Thanks,
> Dimitre

Received on Monday, 7 December 2020 14:17:55 UTC