fogus / ix fork watch download tarball
public
Description: A multi-paradigm programming language
Homepage: http://fogus.me/projects/ix/
Clone URL: git://github.com/fogus/ix.git
ix /
name age message
file .cproject Thu Jun 18 11:55:13 -0700 2009 function params need not be defined with the si... [fogus]
file .gitignore Thu Feb 26 08:04:08 -0800 2009 update ignores [fogus]
file .project Fri Jan 09 16:58:15 -0800 2009 Fix an issue where atoms and variables were not... [fogus]
directory .settings/ Fri Jan 09 16:58:15 -0800 2009 Fix an issue where atoms and variables were not... [fogus]
file README.markdown Loading commit data...
directory doc/ Sun Jan 25 19:18:04 -0800 2009 First cut at the Purpose IXEP (0000) [fogus]
directory etc/ Wed Nov 12 08:15:04 -0800 2008 Doc'n type_list.h [Fogus]
directory src/

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

Functions

Functions are defined via the fn special form:

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

Functions can take a variable number of arguments with the use of the sequence implosion declaration (must always be in the last argument position):

fn( foo [X Y:*_] out("Got " X " with additional " Y crlf))

Function calls are done by following any symbol with a parenthesized set of atoms, variables, or numbers:

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

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 <- foo
call(X 1 2 3)

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

let X <- foo
X(1 2 3)

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.

*_ Sequence expansion/implosion

Used to expand a list into function arguments. This can only be used within a function call:

let X <- _(1 2 3)
out(X)                    ;; prints (1 2 3)
out(X:*_)                 ;; prints 1 2 3

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