-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Thanks to @sgrekhov for bringing up this question.
How does an external function or method handle optional parameters?
I'd think there is no such thing, but we never specified that it is an error to have something like this:
external int foo([int i = 42]);The reason why my first reaction was that this is simply an error is that I wouldn't expect foreign functions to have a notion of optional parameters whose semantics is similar to that of Dart optional parameters. A similar situation might exist with named parameters.
One known use case is js_interop constructors using named arguments to specify desired instance variables and their initial value. Look for 'object literal constructors' here.
Can we say that the semantics is implementation specific, and then it's up to each team who provides support for any given kind of external functions to define the semantics as they wish?
@dart-lang/language-team, WDYT?
@dcharkes, WDYT, do those concepts have a meaningful interpretation with ffi code?