A Smojo Program
What does the program:
"Welcome to Smojo" .
It has two actions:
"Welcome to Smojo"
pushes the text onto the stack. Next the word:
pops the text from the stack and prints the result.
A Much Longer Program
1 2 + .
Try it. How does it work?
pushes the number 1 onto the stack.
pushes the number 2 onto the stack. So, there are two items on the stack, 1 at the bottom and 2 on top.
pops both items off the stack and adds them. It pushes this result back onto the stack. There is now just one item on the stack, the number 3.
pops the top item off the stack and prints it to the console.
Words and Literals
In Smojo, everything is either a Word or a Literal.
.are Words, and they can do things.
"Welcome to Smojo"and
3are Literals. They push themselves onto the stack.
Run this program:
"Down the street the dogs are barkin'" . cr "And the day is a-gettin' dark" . cr
cra Word or Literal? What does it do?
cris a word.
It produces a carriage return, i.e., makes a new line.