You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to compile and execute a playground for every Swift file.
A few important use cases come to mind that can leverage this:
Simple programs which are executable: a program where logic is in a main.swift.
Unit testing. Playgrounds are super applicable to unit testing, since it allows the user to see program state within a test case. This is easier to work with than the existing approach people have adpoted: copying all of the code they want to play with into a playground file.
I think this is a good addition and would make Swift development more interactive overall.
Caveats
Many Swift files don't contain don't contain code that executes, so for a large subset of files, this isn't 100% useful. For example, MyModel.swift is just a class definition.
Alternatives Considered
Copy all of the code in question into a playground.
Implementation
At the compiler level, we are just performing a transform that inserts the playground logging code in a module. I think this pass should work for any file. In my initial testing, it seems to work fine on some sample code.
Pass 1 will use compile_commands.json to get a base a compiler invocation and augment it to include the playground bits.
The text was updated successfully, but these errors were encountered:
It should be possible to compile and execute a playground for every Swift file.
A few important use cases come to mind that can leverage this:
Simple programs which are executable: a program where logic is in a main.swift.
Unit testing. Playgrounds are super applicable to unit testing, since it allows the user to see program state within a test case. This is easier to work with than the existing approach people have adpoted: copying all of the code they want to play with into a playground file.
I think this is a good addition and would make Swift development more interactive overall.
Caveats
Many Swift files don't contain don't contain code that executes, so for a large subset of files, this isn't 100% useful. For example, MyModel.swift is just a class definition.
Alternatives Considered
Copy all of the code in question into a playground.
Implementation
At the compiler level, we are just performing a transform that inserts the playground logging code in a module. I think this pass should work for any file. In my initial testing, it seems to work fine on some sample code.
Pass 1 will use
compile_commands.json
to get a base a compiler invocation and augment it to include the playground bits.The text was updated successfully, but these errors were encountered: