Transpose decomposition of extern definitions per backend
phischu opened this issue · comments
Currently we define extern definitions for each backend separately in a different file and then select which of these files to include based on which backend we are compiling with. For example we have
// libraries/js/text/string.effekt
extern pure def length(str: String): Int =
"${str}.length"
// libraries/ml/text/string.effekt
extern pure def length(str: String): Int =
"String.size ${str}"
This invites incompleteness and incompatibility between backends.
Koka and Idris2 do this differently:
pub extern count( s : string ) : int
c "kk_string_count_int"
cs "Primitive.StringCount"
js "_string_count"
They have a single extern definition with different bodies per backend. Some of them might be missing, which is reported by the compiler only when they would be actually needed.
We should change to this model of extern definitions, which would then probably force us to resolve #309.
Resolved in #449