- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Thu, 3 Dec 2020 09:02:35 -0800
- To: Michael Kay <mike@saxonica.com>
- Cc: public-xslt-40@w3.org, Christian GrĂ¼n <cg@basex.org>
- Message-ID: <CAK4KnZfYJn4fiQbQkrwmXc9Z2Y28MwiuXYE5XLT58Uea5DRzWw@mail.gmail.com>
On Thu, Dec 3, 2020 at 8:03 AM Michael Kay <mike@saxonica.com> wrote: > > 1. Is this definition of one function or of four functions? If this is > a definition of one function, then how do we know that we have seen all of > the definitions (maybe there are more than 4 definitions, but they are > scattered across the code and we cannot be aware of all of them)? > > > It is one function. The arity is two. All the keyword arguments in the > call are combined into a single map value passed to the function > The first two arguments are $input and $pattern. A replace() function is meaningless without providing a replacement, so the arity should be at least 3. So, I am even further confused by this answer. Are you proposing a new function when you don't know what its arity is? Sorry if this is a rather harsh reaction, but better hear it from one person now, than from many people when it is too late. Thanks, Dimitre > > 1. > 2. What is the arity of the function: 2 or 3 or 4 or 5 or 6? If the > answer is 2, how can you explain to a developer that in all the above cases > they are calling a 2-argument function, when they in fact are literally > specifying 3 and 4 arguments? > > > It depends on the developer. If they use Python, they will already be > familiar with the idea of ** arguments: > > def intro(**data): > print("\nData type of argument:",type(data)) > > for key, value in data.items(): > print("{} is {}".format(key,value)) > > intro(Firstname="Sita", Lastname="Sharma", Age=22, Phone=1234567890) > intro(Firstname="John", Lastname="Wood", Email="johnwood@nomail.com", Country="Wakanda", Age=25, Phone=9876543210) > > (Here type(data) outputs <class dict>) > > If they're familiar with varargs in Java, then I would explain it as > saying it's very similar to varargs: there's one parameter defined in the > declaration, which receives a composite value from several arguments > supplied independently in the call. > > > 1. What if some of the keyword arguments are mutually exclusive and > thus shouldn't be specified together on the same function call? Or if we > have two different subsets of keyword arguments that are mutually > exclusive? How can one specify this formally? > > We could try and add that mechanism, but I think it's probably OTT. I > don't see such a mechanism in Python, for example. It's not unusual to have > preconditions on the valid arguments for a function beyond those that can > be expressed formally in the function signature. > > > Such deep changes need scrupulous attention and discussion, so, please, go > gradually, patiently, step by step, and only proceed deeper if you have got > a near-consensus at the current step. > > > Personally, I find it hard to assess the steps without seeing where they > lead. I can only judge whether the feature seems to "work" by defining it > fully and trying it out. The only way to judge whether this mechanism for > keyword arguments is useful is to design some functions that take advantage > of it and see whether they appear usable. That's what I've been trying to > do. > > 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 Thursday, 3 December 2020 17:03:01 UTC