fogus / ix
- Source
- Commits
- Network (0)
- Issues (23)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Aug 06 07:14:38 -0700 2009 | |
| |
README.markdown | Sat Aug 08 18:41:27 -0700 2009 | |
| |
doc/ | Wed Aug 05 05:54:01 -0700 2009 | |
| |
etc/ | Wed Aug 05 05:54:01 -0700 2009 | |
| |
ix.iml | Wed Aug 05 05:56:36 -0700 2009 | |
| |
src/ |
.___
| |___ ___
| |\ \/ /
| | > <
|___|/__/\_ \
\/
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
- Serialize to source
- Any function can (potentially) be infix
- Knowledge as data type
- Anonymous functions
- Extension API
- Loadable modules

