Re: fn:slice()

On Fri, 2020-12-04 at 15:23 -0800, Dimitre Novatchev wrote:
> So, one will call the function with any map as parameter and this
> would be statically OK?

Rght now that's more or less what one does with fn:transform. It's a
bit of an unfortunate example. Yes, you call it with a map.

So Mike's example is exactly what i was suggesting before in this
regard, except i want the keywords to map to named arguments so there
can be useful static type checking. We would need to allow optional
arguments for transform() at least, though, and refer to it e.g. as
fn:transform#*

Then i could call
fn:transform(
  source-node: /,
  stylesheet-location: "remove-namespaces.xsl"
)
and have it behave as if it were defined as
<xsl:function name="fn:transform">
  <xsl:param name="source-node" as="node()" optional="yes" />
  <xsl:param name="stylesheet-location" as="xs:anyIRI" optional="yes"
/>
  <xsl:param name="stylesheet-node" as="node()" optional="yes" />

(or they could have select attributes, as with templates, to indicate
optionality).

Any function could then *either* be called in its positional form, *or*
with its keyword form; since the same function is called, the arity is
the same, and you have to supply all the required (non-optional)
parameters.

Mike i think is proposing something slightly different: that keyword
parameters get put into a map that must then be the only argument of
the function: fn:transform#1 takes a map as input today, and he says
it'd be unchanged. I'd rather see the one or two unusual functions
changed and be able to use keyword parameters everywhere.

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, 5 December 2020 00:31:35 UTC