s2scm Manual

Table of Contents

Next: , Up: (dir)   [Contents][Index]

s2scm Manual


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

1.1 Scheme

Scheme is a multi-paradigm computer programming language that is a dialect of John McCarthy’s LISP programming language.

LISP is notable for supporting the functional programming paradigm, where side-effects are avoided, and for its straightforward ‘S-Expression’ syntax.

This manual assumes basic knowledge of the Scheme programming language. To learn Scheme, you can read the book Structure and Interpretation of Computer Programs.

1.2 Scratch

Scratch is MIT’s educational programming language, targeted primarily at children. It’s very easy to get started with.

You can find Scratch at http://scratch.mit.edu/.

1.3 s2scm

s2scm is a compiler for Scheme that outputs projects for Scratch.

s2scm is written in the Python programming language, and uses the kurt library by blob8108 to output Scratch projects.


Next: , Previous: , Up: Top   [Contents][Index]

2 Installation

To install s2scm, you should have Python 2.7 installed, and the pip or easy_install programs.

2.1 OS X

Computers running Apple OS X have Python and easy_install pre-installed.

If you have administrative previliges, you may simply open up the Terminal and enter the following:

sudo easy_install s2scm

Press the return key after typing the command in.

This will download and install s2scm and all its dependencies.

2.2 Windows

Microsoft Windows does not ship with Python. If you have not previously installed it, you will need to install it now.

Download and install Python 2 from https://www.python.org/. Python versions more than 2.7.9 come with pip, so you will not need to install it seperately.

Now open a Command Prompt and run the command:

pip install s2scm

Press the Return or Enter key after typing the command in.

This will download and install s2scm and all its dependencies.

2.3 GNU/Linux and other UN*X-like operating systems

Many GNU/Linux distributions come with Python and pip pre-installed.

If you don’t have Python and pip installed, you’ll need to install it. The way you do this depends on your distribution.

Assuming you have Python and pip installed, you’ll need to run the following command as the superuser:

pip install s2scm

Next: , Previous: , Up: Top   [Contents][Index]

3 Getting started with s2scm

3.1 Hello world

Here is some example source code you can save in a file:

(say "Hello world!" (+ 1 (* 2 2)))

Save it as plain text in the file hello.scm.

Open a command prompt and change to the directory where you saved the file. This can be done with the cd command on Windows, OS X and GNU/Linux, as well as most flavours of UNIX.

Then, run the following command to compile:

python -m s2scm hello.scm hello.sb2

This will output a Scratch project to hello.sb2.

If you, for example, didn’t want to compile hello.scm but example.scm, you would change the command to:

python -m s2scm example.scm hello.sb2

You can do the same thing for the output file.

Now you can open the Scratch editor, click on the File menu, click “Upload from your computer”, and choose the compiled project. It should also work with the Scratch 2.0 offline editor.

3.1.1 Explanation

The say function is s2scm-specific. It takes two arguments, a string for the Scratch sprite to say, and the duration for how long it will be said.

It corresponds to the Scratch ‘say () for () secs’ blocks.

The + function adds numbers together, and appears in standard Scheme.


Previous: , Up: Top   [Contents][Index]

Index

Jump to:   B   I   K   P   S   W  
Index Entry  Section

B
blob8108: Introduction

I
installation: Installation
introduction: Introduction

K
kurt: Introduction

P
python: Introduction

S
s2scm: Introduction
s2scm, started, getting: Getting started with s2scm
Scheme: Introduction
Scratch: Introduction

W
world, hello: Getting started with s2scm

Jump to:   B   I   K   P   S   W