- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Wed, 2 Dec 2020 08:54:34 -0800
- To: Michael Kay <mike@saxonica.com>
- Cc: Tom Hillman <tom@expertml.com>, Dave Pawson <dave.pawson@gmail.com>, "Liam R. E. Quin" <liam@fromoldbooks.org>, public-xslt-40@w3.org
- Message-ID: <CAK4KnZeBKbN=5ZE7V2_kN2nwE32Z5xE3Hbt9ZWnCrKHknnPCAQ@mail.gmail.com>
> The key is that ALL the keyword arguments are combined into a map, > which is supplied as the final argument of a function whose signature expects a map as its last argument. Then what is the arity of the function? N, or N - count(map:keys($last)) ??? This seems very confusing. Thanks, Dimitre On Wed, Dec 2, 2020 at 8:30 AM Michael Kay <mike@saxonica.com> wrote: > From a first glance it seems to me that allowing default values for > arguments (aka keyword arguments or optional arguments) clashes with our > ability to define function overloads having fewer arguments. > > > I don't think so. The key is that ALL the keyword arguments are combined > into a map, which is supplied as the final argument of a function whose > signature expects a map as its last argument. > > serialize(X) calls serialize#1 > > serialize(X, method:='json') calls serialize#2 - it's essentially just a > shorthand notation for serialize(X, map{'method':'json'}). > > serialize(X, method:='json', indent:=true()) also calls serialize#2 - the > keyword arguments are combined into a single map value, matching the final > argument in the function signature which accepts a map. > > What you can't do using this mechanism is to supply an empty map as the > second argument. If you want to do that, you just call > > serialize(X, map{}) > > but you don't need to, because the fn:serialize function has been designed > so this is equivalent to serialize(X). > > Michael Kay > Saxonica > > On 2 Dec 2020, at 16:21, Dimitre Novatchev <dnovatchev@gmail.com> wrote: > > > > Please, prove me wrong. > > Thanks, > Dimitre > > Sent from my iPhone > > On Dec 2, 2020, at 8:07 AM, Michael Kay <mike@saxonica.com> wrote: > > > > On 2 Dec 2020, at 11:27, Tom Hillman <tom@expertml.com> wrote: > > serialize($x, method: 'json', indent: true()) > > > > I've had a go at speccing this up: see > https://htmlpreview.github.io/?https://github.com/qt4cg/qtspecs/blob/master/specifications/xquery-40/html/xpath-40-diff.html > > Search for "keyword arguments". > > I'm liking it. > > (I used ":=" rather than ":" as the punctuation, but it's easily changed) > > There's a bug in the grammar -- it allows f( , a:= 3 ) -- but hey, it's a > first draft. > > Michael Kay > Saxonica > > >
Received on Wednesday, 2 December 2020 16:54:59 UTC