uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Handling default parameters in functions before non-defaulted parameters

Open badboy opened this issue 1 year ago • 1 comments

This is split out from #1840 and accompanies #1658

The question is how to handle this UDL:

i32 default_first(optional i32 left = 1, i32 right);

(1) not support it?

(2) Should we simply enforce argument names?

def default_first(*, left = 1, right):
    pass

(3) Only move defaulted values to the end?

def default_first(right, *, left = 1):
    pass

(1) is essentially what we do today. (2) is a breaking change, but probably the best option (@mhammond favored this in https://github.com/mozilla/uniffi-rs/pull/1840#discussion_r1409595660) (3) is too weird: suddenly argument order is different from what you haved defined in UDL.

Note that this is all about Python. We should clarify what happens for the other languages too.

badboy avatar Dec 13 '23 13:12 badboy

I think there's a good case to be made that this should work the same as records. cc @jeddai

mhammond avatar Dec 13 '23 14:12 mhammond