Context: I started a patch to implement type mangling for @differentiable functions, and noticed that the current mangling scheme leads to an explosion of function type modifier combinations.
A more flexible scheme could encode multiple modifiers. Sketch:
// Old: modifier is coupled with function type.
// Some modifier information is lost.
kind=ThinFunctionType
kind=ArgumentTuple
kind=Type
kind=Structure
kind=Module, text="Swift"
kind=Identifier, text="Float"
kind=ReturnType
kind=Type
kind=Structure
kind=Module, text="Swift"
kind=Identifier, text="Float"
// New: modifiers are in a separate list.
// Modifier list can be run-length encoded, possibly in a
// backwards-compatible way.
kind=FunctionType
kind=FunctionTypeModifiers
kind=ThinFunction
kind=EscapingFunction
kind=DifferentiableFunction
kind=ArgumentTuple
kind=Type
kind=Structure
kind=Module, text="Swift"
kind=Identifier, text="Float"
kind=ReturnType
kind=Type
kind=Structure
kind=Module, text="Swift"
kind=Identifier, text="Float"
But I'm not sure about the use cases for mangling. If mangling modifiers isn't important, then I suppose there's no need for a more flexible scheme.