Phel is a functional Lisp that compiles to PHP. This section covers the core language features - from basic types and arithmetic through to macros and interfaces.
Work through these pages in order for a guided introduction, or jump to any topic as a reference.
Basic Types
Nil, True, False# Nil, true and false are literal constants. nil true false In Phel, only false and nil are falsy. Ever…
Arithmetic
Arithmetic Operators# All arithmetic operators are entered in prefix notation. # (1 + (2*2) + (10/5) + 3 + 4 + (5 - 6))…
Truth and Boolean operations
Truthiness# In Phel, only false and nil represent falsity. Everything else evaluates to true-including 0, "", and []. T…
Control flow
If# (if test then else?) A control flow structure. First evaluates test. If test evaluates to true, only the then form …
Global and local bindings
Definition (def)# (def name meta? value) This special form binds a value to a global symbol. A definition cannot be red…
Functions and Recursion
Anonymous Function (fn)# (fn [params*] expr*) (fn ([params1*] expr1*) ([params2*] expr2*) ...) Defines a functio…
Data structures
Phel has four main data structures: Lists, Vectors, Maps, and Sets. All data structures are persistent (immutable). A pe…
Destructuring
Destructuring binds names to values inside data structures. Instead of manually extracting each value, you describe the …
Namespaces
Namespace (ns)# Every Phel file is required to have a namespace. A valid namespace name starts with a letter, followed …
Macros
Macros# Macros are functions that take code as input and return transformed code as output. A macro is like a function …
Interfaces
Interfaces define contracts - abstract sets of functions that structs must implement. They map directly to PHP interface…