Hi Florent (good to see you here! :-) ),
Thanks for the clarification and confirmation.
This pattern is very common indeed and I use code like this ("arity
cascade") everywhere. This abbreviation in the documentation makes so
much sense that something like this would have fit very well in the
syntax itself.
Kind regards,
Ghislain
On Wed, Aug 12, 2015 at 4:12 PM, Florent Georges <[email protected]> wrote:
> Hi,
>
> The notation using square brackets in the signature of a function is
> pseudo notation in MarkLogic documentation. The following notation:
>
> hello(
> $first-name as xs:string,
> [$last-name as xs:string?]
> ) as xs:string
>
> is the equivalent of the TWO following functions:
>
> hello(
> $first-name as xs:string
> ) as xs:string
>
> hello(
> $first-name as xs:string,
> $last-name as xs:string?
> ) as xs:string
>
> It is indeed common to have several functions with the same name and
> different arities (different number of parameters), which all
> represent the same "logical function", with some optional parameters.
> They are all documented together on MarkLogic website.
>
> So this is only a documentation convention. XQuery does not support
> varargs, and this is not a MarkLogic extension either. If you want to
> provide real optional parameters (not parameters you can pass the
> empty sequence too, but that you can omit at all), then the closest
> you can achieve is the following:
>
> declare function local:f($a) { f($a, 'default') };
> declare function local:f($a, $b) { ... };
>
> Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>
>
> On 12 August 2015 at 09:15, Tyagi, Devesh wrote:
>> Hi,
>>
>>
>> While using following function
>>
>> sem:rdf-builder(
>> [$prefixes as map:map?],
>> [$graph as sem:iri?]
>> ) as function(item(),item(),item()) as sem:triple
>>
>> we can invoke it as follows
>>
>> sem:rdf-builder().
>>
>> But when I am creating my own function as follows
>>
>> local:get-rdf-builder($prefix-map as map:map*, $graph as sem:iri*) as
>> function(item(), item(), item()) as sem:triple
>>
>> and invoked it as
>>
>> local:get-rdf-builder()
>>
>> It raises the following exception
>>
>> get-rdf-builder() -- Too few args, expected 2 but got 0
>>
>> Works fine for local:get-rdf-builder((),()).
>>
>> I am executing this in Marklogic QConsole.
>>
>> Any help would be appreciated.
>>
>> Regards,
>>
>> Devesh
>>
>>
>> "This e-mail and any attachments transmitted with it are for the sole use of
>> the intended recipient(s) and may contain confidential , proprietary or
>> privileged information. If you are not the intended recipient, please
>> contact the sender by reply e-mail and destroy all copies of the original
>> message. Any unauthorized review, use, disclosure, dissemination,
>> forwarding, printing or copying of this e-mail or any action taken in
>> reliance on this e-mail is strictly prohibited and may be unlawful."
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general