<commit_before># dyon
A rusty dynamically typed scripting language

Notice: This is very early stage in development. Breaking changes will happen!

### List of features

- Array `arr := [a, b, c]`
- Object `obj := {x: a, y: b}`
- Number (f64) `n := 5.3`
- Boolean `t := true`
- Custom Rust objects using `Arc<Mutex<Any>>`
- Functions without return `fn foo() { ... }`
- Functions with return `fn foo() -> { ... return x }`
- Lifetime checker (no garbage collector is needed) `fn foo(a, b: 'a) { a.x = b }`
- Return lifetime `fn id(x: 'return) -> { return x }`
- Checks type at runtime when mutating variable `a = 2.0 // ERROR: Expected assigning to number`
- Objects inserts new key with `a.x := 0` and checks existence and type with `a.x = 0`
- Named argument syntax based on snake case `foo(bar: b)` is equal to `foo_bar(b)`
- If expression `a := if b < c { 0 } else { 1 }`
- For loop `for i := 0; i < 10; i += 1 { ... }`
- Infinite loop `loop { ... }`
- Unlabeled break `loop { break }`
- Unlabled continue `loop { continue }`
- Labeled break `'a: loop { break 'a }`
- Labeled continue `'a: loop { continue 'a }`
- Use `return` as a variable without exiting `return = 8`
- Dynamic modules `m := unwrap(load("script.dyon"))` then `call(m, "main", [])`
- Dynamic imports part of module prelude `m := unwrap(load(source: "script.dyon", imports: [window, graphics]))`
- Add a custom Rust function using `Module::add`

### Why the name Dyon?

Dyon is a hypothetical particle predicted by several grand unified theories in physics with both eletrical and magnetic charge. See [wikipedia article](https://en.wikipedia.org/wiki/Dyon) for more information.

The name Dyon fits because, just like the particle, there are things that are yet to be discovered.
However, it was not born out of a grand new vision about language design,
but is the result of exploring and testing new stuff.

### Motivation and goals

[<NAME>](https://github.com/bvssvni/) started this project in early 2016.
The idea was to make a simple, but convenient scripting language that integrated well with Rust.

- During the first week of coding, it was discovered a way to make a lifetime checking on arguments
- Dynamic modules with imported prelude were added to explore a different approach to organizing code

Main goals:

- Integrate well with Rust
- Flexible way of organizing code
- Performance of the cycle: coding -> parsing -> running -> debugging -> coding

Sub goals:

- Safety

Non-goals:<commit_msg>Added error handling features to README<commit_after># dyon
A rusty dynamically typed scripting language

Notice: This is very early stage in development. Breaking changes will happen!

### List of features

- Array `arr := [a, b, c]`
- Object `obj := {x: a, y: b}`
- Number (f64) `n := 5.3`
- Boolean `t := true`
- Custom Rust objects using `Arc<Mutex<Any>>`
- Functions without return `fn foo() { ... }`
- Functions with return `fn foo() -> { ... return x }`
- Lifetime checker (no garbage collector is needed) `fn foo(a, b: 'a) { a.x = b }`
- Return lifetime `fn id(x: 'return) -> { return x }`
- Checks type at runtime when mutating variable `a = 2.0 // ERROR: Expected assigning to number`
- Objects inserts new key with `a.x := 0` and checks existence and type with `a.x = 0`
- Named argument syntax based on snake case `foo(bar: b)` is equal to `foo_bar(b)`
- If expression `a := if b < c { 0 } else { 1 }`
- For loop `for i := 0; i < 10; i += 1 { ... }`
- Infinite loop `loop { ... }`
- Unlabeled break `loop { break }`
- Unlabled continue `loop { continue }`
- Labeled break `'a: loop { break 'a }`
- Labeled continue `'a: loop { continue 'a }`
- Use `return` as a variable without exiting `return = 8`
- Dynamic modules `m := unwrap(load("script.dyon"))` then `call(m, "main", [])`
- Dynamic imports part of module prelude `m := unwrap(load(source: "script.dyon", imports: [window, graphics]))`
- Add a custom Rust function using `Module::add`
- Option values with `none()` or `some(x)`
- Result values with `ok(x)` or `err(x)`
- `?` operator to propagate errors, e.g. `x := foo()?`, maps option to result automatically
- `unwrap(x)` prints trace of propagated error
- `functions()` returns sorted list of all available functions in a module

### Why the name Dyon?

Dyon is a hypothetical particle predicted by several grand unified theories in physics with both eletrical and magnetic charge. See [wikipedia article](https://en.wikipedia.org/wiki/Dyon) for more information.

The name Dyon fits because, just like the particle, there are things that are yet to be discovered.
However, it was not born out of a grand new vision about language design,
but is the result of exploring and testing new stuff.

### Motivation and goals

[<NAME>](https://github.com/bvssvni/) started this project in early 2016.
The idea was to make a simple, but convenient scripting language that integrated well with Rust.

- During the first week of coding, it was discovered a way to make a lifetime checking on arguments
- Dynamic modules with imported prelude were added to explore a different approach to organizing code

Main goals:

- Integrate well with Rust
- Flexible way of organizing code
- Performance of the cycle: coding -> parsing -> running -> debugging -> coding

Sub goals:

- Safety

Non-goals:
{'fraction_non_alphanumeric': 0.11975028376844495, 'fraction_numerical': 0.007188800605372683, 'mean_word_length': 3.7846153846153845, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2781025', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1548, 'n_words': 745}