On Mon, Nov 09, 2020 at 04:04:06PM +0100, PIERRE AUGIER wrote:
----- Mail original -----
De: "serge guelton" <serge.guelton@xxxxxxxxxxxxxxxxxxx>
À: "pythran" <pythran@xxxxxxxxxxxxx>
Envoyé: Dimanche 8 Novembre 2020 20:44:22
Objet: [pythran] Re: multiple default arguments
On Sun, Nov 08, 2020 at 02:32:27PM +0100, PIERRE AUGIER wrote:
One could then also enable the long form:
#pythran export test(float64, int, (int, int))
#pythran export test(float64, empty, (int, int))
#pythran export test(float64, int, empty)
Not sure if empty is the best keyword here, but can't think of a
better one
what about... default? I like the syntax otherwise ;-)
If we follow a bit https://docs.python.org/3/library/typing.html ;(and
Transonic)
with an Optional keyword, it could be written in one line:
Optional is for optional type. here we want a way to epress that we use the
default value (and thus its inferred type)
Yes, in typing.Optional[int] means typing.Union[int, None] (where None
actually means NoneType).
However, it's not optimal that one needs 2**n signatures to express that n
arguments have a default value (as with the proposed solution if I understand
correctly).
Is there a drawback to have something like Optional[a_type] to express that
with much less signatures? Something like
#pythran export test(float64, WithDefault[int], WithDefault[(int, int)])
or
#pythran export test(float64, int or default, (int, int) or default) ?