using a Playground and drop in your framework of choice and then use the framework inside the playground?
I think you can do this already -- but (in my understanding) what you can't do is get the Playground Inspectable experience from any of the code within the framework
write an application that can use input from a bundled playground, so I can play around with values in the playground and the app reacts?
Yeah that's what I'm after -- particularly for code within the top-level playground file. The other bundled code within the playground (regular .swift files) are directly shareable with an application/library -- however those code files do not receive the playground inspectable value treatment when invoked in the playground -- (unless my understanding is wrong) the only file that gets the full Playground Inspectable experience is the special file where the top-level expression syntax is allowed which cannot be directly invoked from an application/library
My (not well articulated) thought was that it seems like there is (always?) a kind of semantic substitutability between a function with default arguments and a playground file with the special top-level expression syntax -- or at least there must be a large subset of cases where this is so:
Simple (perhaps too simple) example: this function:
func someApplicationFunction(text: String="Pointless Example", count: Int=10) {
let exampleIntermediateState = String(count: count, repeatedValue: text)
}
Is equivalent to something like this playground:
// func someApplicationFunction(text: String="Pointless Example", count: Int= 10)
let text = "Pointless Example"
let count = 10
let exampleIntermediateState = String(count: count, repeatedValue: text)
Does this imply that it should be possible to support playground like interaction modes for function's with default arguments that exist within application/library targets?
My first notion was to expand the syntax allowed in the top-level playground context so that a playground could be invoked as a function inside an app target while also being interacted with as a playground -- something which is currently impossible because the syntax of a playground file is different from that which can be incorporated in any swift compilation context other than playground file's and main.swift.
If swift was extended so that the below someApplicationFunction.swiftscript file when compiled within a module produced a function func someApplicationFunction(text: String="Pointless Example", repeatedValue: Int= 10) that could be called:
let text = receive_parameter(text: "Pointless Example")
let count = receive_parameter(count: 10)
let exampleIntermediateState = String(count: count, repeatedValue: text)
This would allow one to interact with the body of a function in a playground environment while also invoking that function within an application ... This by itself would be useful as it would allow one to prototype functions inside playgrounds that could be directly invoked within applications/libraries.
Beyond that, my dream is that if playground's are just syntax sugar for a particular kind of function definition, then perhaps whatever special compilation support is needed to support the playground feature-set might also be suitable to apply to any compatible function defined normally ... It would be really cool if you could trivially enter an interactive development environment for any swift function in your codebase in a lightweight way simply by providing the minimal required information: 'run this function with these arguments'.
Perhaps clarifying the similarity between playground's and functions could ensure that the compilation behavior necessary to support playground functionality be made independent of the top-level expression syntax so that it could also be used for directly prototyping the body of normal function defined in a library/application.