I'm looking at some of the Apple-supplied sample playgrounds, like the "Answers" playgroundbook, and there seem to be APIs that are magically injected. For example, the first page of “Answers” is called “Text,” and contains:
show("What’s your name?")
let name = ask("Name")
show("Hi " + name)
Where do these show and ask functions come from? Are they documented someplace?
They are not in any file that's visible from the Swift playgrounds app. If I dig into the playground package, I can find them in Contents/Modules/Book.playgroundmodule/Sources/PlaygroundAPI/AnswersPlayground.swift, but I guess that's something that's only visible from Xcode, when you're authoring these things?
I think it's on purpose because people who use Playground are usually swift beginners. The purpose is to learn the basic Swift grammar not the implementation.
Not quite, but it's stashed away rather well. You can find it in the ...-menu under Advanced -> View Auxiliary Source Files, and drill down into the folder structure from there.