[Idea] A way to build an arguments list dynamically


(Eugene Gubin) #1

Hi,

This is not a proposal, just a sketch. I think this could be convenient for
DI frameworks for example.

func resolve<Params, Result>(factory: Params -> Result) -> () -> Result {
    return {
        let pParams: Params =
#signature(factory).params.build(createParameter)
        return factory(pParams)
    }
}

func createParameter<Parameter>() -> Parameter {
    fatalError("Somehow")
}

Any thoughts?