Skip to content
Will Spear edited this page Nov 29, 2015 · 1 revision

Arcadia Quickstart Guide

If you're looking to hit the ground running, you're in the right place. This guide assumes prior experience with a lisp-family language and only covers the most prominent differences between Arc and other common lisp dialects. If you're trying to hunt down a specific feature or familiarize yourself with the Arc language in general, you probably want the official documentation.

Starting off

-- todo: link to page on building arcadia --

You can execute files directly, or run arcadia with no arguments to get a REPL. In either case, bringing files into the current scope is done with load. Once you load a file, you can access functions and variables defined within it. Keep in mind however that loading a file essentially executes it, so in most cases you'll want to make sure the file you're loading doesn't contain anything other than definitions.

[you@box] $ ./arcadia
Arcadia 0.9.24
> (load "./some_code.arc")
nil
> (function-defined-in-some-code-file)
"Dang, that's a real long function!"
> 

Output

There are several functions capable of writing to stdout, but prn and disp cover 90% of use cases. Use prn when you want arcadia to append a newline automatically, and disp when you don't (e.g. for a prompt or something).

> (prn "Hello World")
Hello World
> (disp "This is the same\n")
This is the same
> (disp "This isn't")
This isn't> ; see the difference?

Concatenating strings can be accomplished easily with string, which takes any number of arguments (all of which must be 'string types themselves) and returns a single string which is their concatenation. You have to use coerce to convert other types into strings before printing them.

> (prn (string "The result is: " (coerce (* 8 5) 'string)))
The result is: 40

Input

Use readline to grab input from the user. You can combine this with disp and get a nice-looking prompt:

> (prn (string "Your name is " (do (disp "Enter your name: ")(readline))))
Enter your name:

Assignment

You can use assign or = to bind values to symbols. Unlike many other Lisp dialects, no special "destructive" method is required to change the value of an existing variable; assignment and reassignment are syntactically identical.

> (= x 10)
10
> (= x 100)
100

Functions can also be bound to symbols. This is Arc's take on the lambda operator often found in other dialects, and works in the same way.

(= useless-function (fn () (prn "This is a function!")))

You can also use the def macro, which provides some syntactic sugar that makes function definitions easier to read.

(def useless-function () (prn "This is a function!"))

Other features

All the major things have been covered, but Arc provides some smaller unconventional features as well. Most confusing by far to those coming from CL would be the square brackets. They work exactly like they do in Racket though, so there's no shortage of resources in that regard.

-- todo: macros?

Clone this wiki locally