Re: anonymous functions? anonymous variables

Dimitre Novatchev <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <CAK4KnZdRyM=sV=4xDEy+mdT4e7E0SPn=6EQMVGoZFJH_akYAyg@mail.gmail.com>
So, if I understand the suggested improvement,

function($k, $v){$k}

will be written as:

  function($k, _){$k}

Hmm... this actually saves us writing just one character and doesn't seem
like a huge improvement, or is there something else I am missing?

We could even have (in a future XPath version):

   function($k, ){$k}

or generally something like:

  function($p1, , $p3, , , $p6 ) { Expr($p1, $p3, $p6) }

and it seems even better to have named parameters and specify them by name
-- regardless of order.

If we don't have the ability to specify a name for each argument in the
function declaration, then we would need to identify a specific argument by
its position number, which, I agree, is not as convenient as referring to
these by name.

To summarize, it seems that providing the ability for named arguments is a
good solution to the problem. If I remember well, Dr. Kay had something
like this in his XML Prague 2020 paper.


Dimitre

On Sun, Aug 16, 2020 at 1:57 PM Ihe Onwuka <[email protected]> wrote:

>
>
> On Sun, Aug 16, 2020 at 1:43 PM Dimitre Novatchev <[email protected]>
> wrote:
>
>> > I have to write
>> >
>> >    function ($k, $v) {$v}
>> >
>> >    instead of something like
>> >
>> >    function (_,$v) {$v}
>>
>> What is the rationale to have the signature of the function contain an
>> unreferenced argument? Why not use just:
>>
>>   function ($v)  { (: Expr :)}
>>
>>
> It may be a constraint imposed by the context in which the function is
> being used. See for example
> https://www.w3.org/TR/xslt-30/#func-map-for-each where the function
> supplied must have two arguments whereas the use case only requires the use
> of one.
>
>
>

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.