KC3 is currently a programming language project, inspired by C, Elixir and Common Lisp. It could be described as C with Elixir modules, pattern matching, and a semantic object system. The idea is to plug modules, closures, pattern matching, a graph database and metaprogramming into C99 with an extremely small set of dependencies.
Supported operating systems (additionnal dependencies) :
Supported architectures :
Everything in KC3 is in a module. A module is a namespace,
and is named with a symbol starting with a uppercase character.
For instance Sym
and Str
are valid module names.
Use defmodule to define a module. Example :
defmodule Test do
def one = 1
def double = fn (x) { x * 2 }
def add = cfn Tag "tag_add" (Tag, Tag, Result)
end
Each module can define a type and a module name can also be a type name if the corresponding module defines a type.
Use defstruct to define a struct type in a module. The struct will have the same name as the module. Example :
ikc3> defmodule Test do
ikc3> defstruct [x: (F32) 0.0,
ikc3> y: (F32) 0.0]
ikc3> end
ikc3> a = %Test{}
%Test{x: (F32) 0.0,
y: (F32) 0.0}
ikc3> a.x
(F32) 0.0
ikc3> a.y
(F32) 0.0
The module can also include definitions for constants or functions for operating on the module type or other types.
The default module is KC3
, which is defined as facts (triples)
in lib/kc3/0.1/kc3.facts
.
Basic data types in KC3 are :
Str
, e.g. "Hello, world !"
Sym
, e.g. :hello
or Hello
Bool
, true
or false
S8
, S16
, S32
, S64
, Sw
U8
, U16
, U32
, U64
, Uw
Integer
Ratio
, e.g. -2/3
F32
, F64
, F128
Complex
, e.g. 1 +i 2
List
, e.g. [1, 2, 3]
Tuple
, e.g. {:ok, 123}
Map
, e.g. %{id: 1, login: "dx"}
%GL.Sphere{}
Quote
, e.g. quote quote 1 + 2
Ident
, e.g. quote List.map
Call
, e.g. quote sqrt(1)
, quote 1 + 2
Block
, e.g. { 1 + 2; 3 + 4 }
Fn
, e.g. fn (x) { x * 2 }
Cfn
, e.g. cfn Tag "tag_add" (Tag, Tag, Result)
Unquote
, e.g. quote 1 + unquote(x)
Var
, e.g. ?
Void
, e.g. void
Top : KC3 documentation
Previous : 1 KC3
Next : 1.2 Integer