Re: fn:slice()

Liam, your proposal is the best so far.

If keyword arguments are defined off a record, without '*' as the last
member, then this will allow static typing and is the right way to go.

However, *I strongly support your proposal *to add support for
specifying within a function definition that an argument is optional and
its default value. Done this way, no record / tuple type is needed, and
this is a better solution, because it doesn't involve any new data type. It
also tells the people correctly that the function has 10 different
arguments and not just one. The fact that this may be implemented using a
record is completely implementation-dependent and the developer doesn't
need to be aware of such implementation detail.

Thanks,
Dimitre

On Fri, Dec 4, 2020 at 4:31 PM Liam R. E. Quin <liam@fromoldbooks.org>
wrote:

> 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 02:03:29 UTC