Re: Proposal for variadic functions

On Tue, Dec 8, 2020 at 8:36 AM Michael Kay <mike@saxonica.com> wrote:

>
> If a function is variadic, then its name must be unique within the static
>> context.
>>
>
> Does this mean that there cannot exist two variadic functions with the
> same name, for example
>
>     myFun($arg1, $arg2, $arg3 default: 0 )
>
> and
>
>       myFun($argName1, $argName2 default: 3 )
>
> If so, why is this restriction?
>
>
> To keep the rules simple and understandable, and to enable simple and
> clear error messages when people get things wrong. It would be possible in
> theory to have one function F with arity range 1-2 and another with arity
> range 3-5, but things like function-lookup would all get unnecessarily
> complicated.
>
> In your example, which function would myFun(1, 2) invoke?
>

This will result in error. One will use any of these two function calls

    myFun(arg1: 1, arg2: 2)

or this

   myFun( argName1 : 1, argName1 : 2)



>
>
>> A variadic function can be identified by a function reference of the form
>> name#*. fn:function-arity applied to a variadic function returns ();
>> fn:function-lookup and fn:function-available accept a second argument of ()
>> to identify a variadic function.
>>
>
>
> I think it would be more precise to have: name#m-n  where m is the number
> of positional/required arguments and n is the number of keyword arguments.
>
>
> Well, firstly, this doesn't parse unambiguosly. One could solve that with
> a different syntax such as name#(m-n) but it just seems unnecessary
> complexity; you're providing users with extra rope to hang themselves by.
>

Disagreed (re: unnecessary complexity). And it is generally true that tools
can be used also in a damaging way, nothing new here, or specific for this
refinement.


>
>
> As other people asked, I don't understand what "virtual fixed-arity"
> function means. Please, elaborate and provide an example.
>
>
> I hope my explanations to Norm Tovey-Walsh and Reece Dunn explained the
> general idea. Obviously the detailed spec remains to be written.
>


Nope, maybe I am still not fully awake. The word that halts my thinking
process is "virtual". Seems like if we accept arity to have two components
this all "virtuality" will be unnecessary? Extra rope to hang themselves?
:)

>
>
>>
>> Because in a function call we can reference now any argument by name
> (even a positional argument), we must specify a restriction that the (names
> of the) keys of the map do not clash with the names of the positional
> arguments, or to allow in this case a mechanism for disambiguation,
> something like:
>
> This is why I specified that arguments supplying parameters prior to the
> final map parameter cannot use keywords, they must be specified
> positionally.
>

This is completely unnecessary, restricting and damaging the completeness
of this unified proposal.

-10

Thanks,
Dimitre


>
> Michael Kay
> Saxonica
>
>

-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Received on Tuesday, 8 December 2020 16:50:09 UTC