A rusty dynamically typed scripting language
Tutorial
Dyon-Interactive
Dyon Snippets
/r/dyon
Dyon script files ends with ".dyon".
To run Dyon script files from command line, type:
cargo install --example dyonrun dyon
Then, to run a script file you type:
dyonrun <file.dyon>
Dyon for the Atom Editor
Dyon for the Vim Editor
arr := [a, b, c]
obj := {x: a, y: b}
n := 5.3
t := true
link { 1 2 "hi" false }
Arc<Mutex<Any>>
fn foo() { ... }
fn foo() -> { ... return x }
f(x) = x / (x - 1)
ns program::example::test
fn foo(mut a, b: 'a) { a.x = b }
fn foo(mut a) { bar(mut a) }
fn id(x: 'return) -> { return x }
a = 2.0 // ERROR: Expected assigning to number
a.x := 0
and checks existence and type with a.x = 0
foo(bar: b)
is equal to foo__bar(b)
a := if b < c { 0 } else { 1 }
for i := 0; i < 10; i += 1 { ... }
for i 10 { ... }
for i [2, 10) { ... }
for i { println(list[i]) }
for i, j { println(list[i][j]) }
∑
/sum
, ∏
/prod
, min
, max
, sift
, ∃
/any
, ∀
/all
loopswhy(any i { list[i] > 3 })
loop { ... }
loop { break }
loop { continue }
'a: loop { break 'a }
'a: loop { continue 'a }
return
as a variable without exiting return = 8
m := unwrap(load("script.dyon"))
then call(m, "main", [])
m := unwrap(load(source: "script.dyon", imports: [window, graphics]))
Module::add
none()
or some(x)
ok(x)
or err(x)
?
operator to propagate errors, e.g. x := foo()?
, maps option to result automaticallyunwrap(x)
prints trace of propagated errorfunctions()
returns sorted list of all available functions in a modulefn could(list: []) -> f64
fn players() -> [Player str] { ... }
fn render() ~ world { ... }
go
thread := go foo()
receiver := in foo
\(x) = x + 1
\(x) = (grab a) + x
f32
precision (x, y, z, w)
vec4 i f(i)
f(xy v)
(yxz v, 1)
#fab3ee
dyon_fn!{fn say_hello() { println!("hi!"); }}
Dyon is a hypothetical particle predicted by several grand unified theories in physics with both electrical and magnetic charge. See wikipedia article for more information.
The name Dyon fits because, just like the particle, there are things that are yet to be discovered about language design. However, this language was not born out of a grand new vision, but is the result of exploring and testing new ideas.
Sven Nilsen started this project in early 2016. The idea was to make a simple, but convenient scripting language that integrated well with Rust.
?
operatorMain goals:
Performance will be optimized for the cycle:
coding -> parsing -> running -> debugging -> coding
Sub goals:
Non-goals:
Licensed under either of * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.