Comment by RodgerTheGreat
9 hours ago
The alert[] function prompts the user for input. The second "string" argument indicates the prompt will ask for a string, and return it. (alert[] can also ask for other datatypes, like a yes/no "boolean" prompt or a multi-choice selection from a list or dictionary of options.)
The colon (read aloud as "becomes" or "gets") is Lil's assignment operator. That single line,
myname.text:alert["What is your name?" "string"]
prompts for input and then stores the result in a card field. If you wish, you could also write it as:
on click do
name:alert["What is your name?" "string"]
myname.text:name
end
Learning the syntax for calling functions is partially scaffolded by the "Action..." dialog that button widgets offer for constructing simple button scripts with a GUI:
on click do
go["Next" "BoxIn"]
play["sosumi"]
end
Users can rely on the system to write code for them initially, and then slowly dip their toes into more complex compositions. Whereas HyperTalk has custom syntax for almost every programming construct and built-in function or feature, the Lil grammar is simple and uniform. Where symbols appear, they have a single meaning. Decker's "Listener" REPL allows the user to have a back-and-forth "conversation" with the Lil interpreter and see responses juxtaposed with their questions, versus the HyperCard "message box" which shows only user input or a single system response.
Ultimately, every programming language does require some degree of handholding and learning, and that's why Decker comes with dozens of example decks to take apart and study. The user community has also furnished some truly fantastic interactive tutorials:
No comments yet
Contribute on Hacker News ↗