Chapter 2. Print things out

The first thing you need to do to start playing with any language is to find a way to print things out. An example of the use of the 'print' operator, which prints the item at the top of the stack out to the standard output, is shown below:

Example 2-1. Printing Hello World

Program Listing

"Hi World!\n" print

Program Output

Hi World!

But how do we run this? There are two methods; the first is to use Ripley in an interactive mode. Where everything you type is immediately evaluated by Ripley. The example below shows how to do this:

Example 2-2. Using Ripley Interactively

Command Line

./ripley -f examples/terminal.ripley

Program Output

Interpreter for Ripley, version 0.1
Ripley (blank line to exit) > 

The next method is to create a new text file with your Ripley commands, and then to use Ripley to execute it directly. The below shows how to do this:

Example 2-3. Using Ripley With A File

File: test.ripley

"Hello World!" print

Command Line

./ripley -f test.ripley

Program Output

Hello World!