Just a quick suggestion... following on from @dynamicCallable logger I was wondering if any thought had been given to usings defaulted parameters with static literals in @dynamicCallable types?
static callables look fantastic. But I really like the call site for my simple Logger type as I can label each argument without fuss. As swift can't reflect the name of the passed argument, I find myself chronically writing things like...
print("edits:", levenshtein.edits, "pathgen.count:", pathgen.count)
// (I don't actually use a raw `print` call):
I definitely prefer the @dynamicCallable class Logger syntax:
var log = Logger()
log(edits: levenshtein.edits, pathgenCount: pathgen.count)
As of swift 5.1, string interpolation is broken in the dynamicallyCall(withArguments:) and dynamicallyCall(withKeywordArguments:) methods, so it's hard to be sure. But until the swift compiler has beefier reflection (if ever) manually writing out labels for debug and logged data, especially in testing and playground code, seems inevitable. See DefaultStringInterpolation cannot be used as an argument for DynamicCallable
I did manage to get interpolation working by using a class-based implementation of StringInterpolationProtocol on a custom type, but had to misuse ExpressibleByArrayLiteral in lieu of a ExpressibleBy<T> (this works for a fake ExpressibleByTuple too ) I'll post the code back on the original thread.
Here are a couple of callsite examples:
log("\(0...1, label: "closed")", "\(2..<3, label: "halfOpen")") // using ExpressibleByStringInterpolation
log(partialUpTo: [...4], partialFrom: [5...]) // using ExpressibleByArrayLiteral
I definitely prefer typing the second form. (the array notation notation is only needed if you want string interpolation support before swift 6.