Re: fn:slice()

I think the bar for new syntax should be much higher than the bar for new functions. Although there might be concerns about "using up" the available space of function names, the space available for functions is vastly greater than the space available for new operators, and we shouldn't use it where a (higher order) function can do the job.

Incidentally, people are much more likely to find what they're looking for if it's in the function library rather than custom syntax. People are often slow to discover than arithmetic operators work on dates and times, and I answered a question today from someone who had failed to discover the array{} construct - he had been searching the function library for an equivalent.

Michael Kay
Saxonica



> On 4 Dec 2020, at 18:01, Liam R. E. Quin <liam@fromoldbooks.org> wrote:
> 
> On Fri, 2020-12-04 at 18:27 +0100, Christian GrĂ¼n wrote:
>> How do people feel about the third fn:filter argument that I proposed
>> in this thread?
> 
> It starts to feel to me as if a syntactic construct would be more in
> keeping:
> 
> for $matthew in slice of $mark from position = 1 to $john where . mod 2
> return $matthew * $luke
> 
> Overall i'm fine with {...} representing a block of code (as in Perl,
> just as i first encounered a slice operator ("..") in Perl) but
> something simple seems to be becoming very complex.
> 
> XPath is used standalone, with XQuery and with XSLT, and the target
> audiences overlap only slightly i think.
> 
> A simpler rule might be that you can always supply *either* positional
> arguments *or* named arguments,
>    replace(input: ., regex: $pattern, collation: $speaker, $replace-
> code: { $2 || $1 })
> 
> However, this would require making sure all the functions in F&O had
> sensible parameter names instead of item1 and item2 or whatever, as
> they'd enter the API.
> 
> Supplying options in a map might be done with something like,
>    replace(arguments : $map)
> where arguments would be a reserved word.
> 
> 
> 
> 
> -- 
> 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 Friday, 4 December 2020 18:14:44 UTC