fogus / ix

A multi-paradigm programming language

This URL has Read+Write access

ix /
name age message
file .gitignore Thu Aug 06 07:14:38 -0700 2009 ignoring eclipse files [fogus]
file README.markdown Sat Aug 08 18:41:27 -0700 2009 stud for ns [fogus]
directory doc/ Wed Aug 05 05:54:01 -0700 2009 fmt [fogus]
directory etc/ Wed Aug 05 05:54:01 -0700 2009 fmt [fogus]
file ix.iml Wed Aug 05 05:56:36 -0700 2009 IDEA proj file [fogus]
directory src/ Loading commit data...
README.markdown
.___
|   |___  ___
|   |\  \/  /
|   | >    <
|___|/__/\_ \
           \/

Ix is a multi-paradigm programming language directly supporting OOP, functional, procedural, meta-programming, and production-based programming methodologies. Notes about its development can be found on my blog.

Vars and Values

Values are bound to symbols using the let function:

(let A 42)

Vars are represented using a name starting with an uppercase letter

Vars are immutable, but can be rebound:

(let A 2)
(let B A)
(out A)    ;; prints 2
(out B)    ;; prints 2
(let A 3)
(out B)    ;; prints 2

Vars that are not bound have the value nothing

(let A Ihaveneverbeenbound)
A         ;; prints `nothing`

Functions

Functions are defined via the fun special form:

(fun foo [X] (out "Got " X crlf))

Functions can take a variable number of arguments with the use of the ellipsis prior to the variable arg

(fun foo [X ... Y] (out "Got " ,x " with additional " ,y crlf))

Function calls are done by following a left-paren with a symbol followed by a set of atoms, variables, or numbers:

(foo 1 2 3 "foo" a b c [x y z])

This is known as S-Expression form.

Function names are simply symbols and can be called indirectly via call:

(call foo 1 2 3))

Since function names are symbols, they can be stored in variables and also called indirectly:

(let X +)
(call X 1 2 3)   ;; gives 6

If you prefer, the variable holding the function name can be used in the function call form directly:

(let X  +)
(X 1 2 3)        ;; gives 6

Namespaces

TBD

Directives

Directives are used to change the normal behavior of Ix. They are indicated using the colon operator and often appended to the end of function name or variables or stand on their own in certain positions.

ever Infinite looping

Used to make the for function operate as an infinite loop. Typically, the for function operates on a list, iterating through each of the elements one at a time. However, with the ever directive, it can be made to operate like a while(true) loop.

;; Normal for loop
(let X [1 2 3])
(for E <- X
  (out E))                      ;; prints 1 2 3

(for :ever
  (out "Hello Cleveland "))     ;; prints Hello Cleveland forever

index Gets the current loop index

Used the grab the current index of a loop. It is appended to the end of the loop variable to access.

(let X [a b c])
(for E <- X
  (out E @ E:index " "))    ;; prints a@0 b@1 c@2

TODO

  1. Serialize to source
  2. Any function can (potentially) be infix
  3. Knowledge as data type
  4. Anonymous functions
  5. Extension API
  6. Loadable modules