Hello! I've encountered some behavior in C-FFI that I would like to discuss.
When you try to define an enumeration containing duplicate values, C-FFI
gives the error:
"A foreign enum cannot contain duplicate values: 0."
However, C enumerations can contain duplicate values, and this feature is
used by real code. FLTK, for example,
uses it to provide for source compatibility when the name of enumeration
elements are changed. Without direct
C-FFI support for this feature, the resultant C-FFI bindings do not
translate well to what the user expects (enumeration
keys available in the C header are not available in the Lisp binding).
Verrazano works around this issue right now (by discarding duplicate keys),
but it's a sub-optimal solution,
since there is no way to programatically determine a consistent set of keys
to discard. For example,
FLTK contains an enumeration in which FL_ALIGN_TOP_LEFT and
FL_ALIGN_LEFT_TOP alias each other,
and FL_ALIGN_TOP_RIGHT FL_ALIGN_RIGHT_TOP alias each other. Depending on the
ordering in the header file,
the enumeration may end up containing an inconsistent set of names (eg:
FL_ALIGN_TOP_LEFT and FL_ALIGN_RIGHT_TOP).
Sincerely,
Rayiner Hashem