Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lispen

A Lisp-like programming language written in Rust.

Syntax

Lispen follows the same syntax as some Lisp dialects:

(println "Hello World")

The example above is a list, which, by default, is interpreted as a function call if the first argument is an identifier.

Defining variables

To define a variable in Lispen, you use the set keyword.

(set x 10)

This will bind the value 10 to the variable x in the current scope.

Types

  • num
  • str
  • bool
  • list
  • fn
  • nil

Numbers

All numbers in Lispen have the same type, num, and it supports both integers and floats.

Note: inside the interpreter this type is represented by a f64.

Arithmetic

Lispen, like other Lisp dialects, uses the Polish notation to represent arithmetic.

This is the syntax:

(operator operand1 operand2)

Example of a sum:

(+ 1 2)

Lists

Like explained above, lists can represent function calls, if the first argument is an identifier.

But you can also make the list be interpreted as a literal list, even if the first argument is an identifier.

Use the quote ' character before the list:

'(println 10)

In this case, it'll be evaluated to a list with two elements, a function and a number.

Functions

There are two ways of defining functions in Lispen: using the defn and the fn keywords.

Every function creates a new scope inside it.

defn

defn defines a function and also binds it to a name.

(defn f(x) (+ x 1))

fn

fn only defines a function.

(fn(x) (+ x 1))

To assign it to a name, you can use the set keyword.

(set x (fn(x) (+ x 1)))

About

A Lisp-like programming language written in Rust.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages