Skip to content

CEP-0043: Exported Methods and Generic Specializations

Draft

Draft proposal for exporting methods and generic specializations through external ABIs. V1 exports only free function definitions with C-safe scalar signatures.

Summary

Catalyst should eventually decide whether inherent methods and selected generic specializations can be exported as external ABI symbols.

V1 @export(.c) is valid only on free function definitions with bodies.

Example

Possible future shape:

const Gain = struct {
  value: f32

  @export(.c)
  fn apply(self: *const Gain, input: f32) f32 {
    return input * self.value
  }
}

V1 users write an explicit free function wrapper with the desired C-safe signature.

Motivation

Exporting methods and specializations can make interop APIs more direct. It also needs explicit receiver lowering, symbol naming, specialization identity, and ABI validation.

Proposed Direction

The proposal should cover:

  • receiver-explicit lowering for exported methods;
  • naming and @link_name defaults;
  • selecting generic specializations for export;
  • ABI validation after specialization;
  • generated header behavior;
  • visibility and duplicate symbol diagnostics.

V1 Compatibility

V1 users write explicit free function wrappers for exported method-like or specialization-specific APIs.