Re: Function naming: Problems and proposed solution

Hi,

alternatively, rather than introducing a new function call syntax, there 
could be a simpler, new map constructor syntax. So one could write:


serialize($x, {method: 'json', indent: true})

where it does not allow node tests as keys or even values.


Bye,
Benito
On 02.12.20 11:56, Michael Kay wrote:
>
>
>> On 2 Dec 2020, at 09:58, Tom Hillman <tom@expertml.com 
>> <mailto:tom@expertml.com>> wrote:
>>
>> I see more and more functions taking an options map as the final 
>> argument...
>>
>
> And perhaps that could be formalised into the language syntax so 
> instead of
>
> serialize($x, map{'method':'json', 'indent':true()})
>
> you can write
>
> serialize($x, method: 'json', indent: true())
>
> Specifically, any keyword: value pairs in the function call are 
> gathered together into a map, which is supplied as the last argument 
> of the call, and the above call is treated as a call on the arity=2 
> function because there are one-or-more keyword:value arguments supplied.
>
> I write calls like that a lot in xsl:message for debugging, and 
> simplifying the syntax would be a very useful convenience.
>
> If the function signature declares the options parameter as a record 
> type rather than a general map type then it also gives you the 
> opportunity for static checking that the option names are right.
>
> Michael Kay
> Saxonica
>

Received on Wednesday, 2 December 2020 12:56:42 UTC