Skip to content

Implement idiomatic optional return values

This MR implements support for idiomatic optional return values as discussed as part of #159. Depends on !185.

Design

Functions can declare a sentinel that represents an empty value, with the fct_none_sentinel_val config option. Language FFIs can then replace that sentinel with the language's idiomatic way of representing empty values:

  • in Rust: the Option<T> type
  • in OCaml: the 'a option type
  • in JavaScript, PHP, Python: null/None values

This could be extended in the future to include:

  • Haskell: the Maybe a type
  • C#: T? types
  • C++: the std::optional type
  • Java: more nulls?

Merge request reports

Loading