Photon is a language and compiler. It is statically typed with a type system that is closely related to that of C. It is also dynamically executed in a way that is similar to most Lisp implementations. It aims to provide the performance and simplicity of C while having the flexibility and power of Lisp.
The compiler compiles the Photon code into C code. The C code is then compiled by a compiler to produce efficient(-ish) native code. Currently the compiler used is TCC, which generates relatively slow assembly code.
This compiler is in a very early stage of development, please dont expect anything to work yet.
To test the compiler I am trying to build some games examples of these are 'growth.lisp' and 'simple_game.lisp'.
Check out the file test.lisp to see the current functionality.
Only works on 64bit Linux at the moment.
- mkdir photon
- cd photon
- git clone git@github.com:rolfrm/Photon.git
- git clone git@github.com:rolfrm/iron.git
- cd Photon
- make
- ./foton growth.lisp ;; run the 'growth' game.
- ./foton repl.lisp ;; run the REPL.
- Naming symbols anything.
- Global variables.
- setf
- floats / doubles
- Loading lisp code
- Proper symbols - one symbol - one ID. Symbols to be used for functions, variable names. This meams that vars will be symbol based instead of string based.
- Quoting 'symbolname
- Opaque types
- c-macros - Register the functions/types needed to work with macros.
- Equality "eq"
- conditionals "if"
- loops (while expr body) result is the output of the last item.
- a better REPL (history, multi-line, line-edit)
- Structs
- Defining - structs can be defined using the type macro
- member access
- Arrays / pointers - c-style deref
- address off. (ref obj)
- sizeof macro - size calculated at compile time.
- Lisp macros (tick/backtick syntax) choosen expr/unexpr equal of tick/backtick
- ffi
- literal hex values
- Standard library - use ffi to bind c std lib
- libc
- -ldl related
- -lm related
- function overloading macro / varadic functions
- macros that do not require 'expand
- proper function printing (needed for callback functions). using printers, a bit slow..
- faster type-of macro (current version requires compiling the code to check the types. Better to just do it once. Memorizing?
- Call function pointers
- proper interned literal strings (checkout tries. no probably to hash tables instead.)
- Waste less memory
- Bugs / Stability
- better error handling
- line number of exprs.
- lvalue checking (setf 1 10) is invalid for instance. (setf a 10) might be ok.
- Windows 64bit support.
- Windows/Linux 32 bit support
- Recursion support
- Packages / Modules
- libgccjit backend.
- (and/or) Use user selected compiler backend. Fallback to tcc if necessesary.
- Compile working image into a c-compatible static or dynamic link library and header file.
- Front end optimizations like tail call optimizations, function inlining and constant propagation. Note: pure functions can be evaluated during constant propagation.
- Bignums (can be built into the language)
- inline assembly
- SSE support (made with inline assembly)
- enums
See License file.