Crate dyon

Crate dyon 

Source
Expand description

§Dyon Crates.io Crates.io

A rusty dynamically typed scripting language

fn main() {
    println("hello world!")
}

DYON-API | LICENSE-APACHE | LICENSE-MIT

§Introduction

Tutorial
Dyon-Interactive
Dyon Snippets
/r/dyon

Dyon script files end with .dyon.

To install Dyon REPL, type:

cargo install --example dyon dyon

Then, to run the Dyon REPL, type:

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>

§Editor-plugins

Dyon for Atom
Dyon for Vim
Dyon for Visual Studio Code

coding

§List of features

§Why the name Dyon?

Dyon is a hypothetical particle predicted by several grand unified theories in physics with both electrical and magnetic charge. See this 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.

§Motivation and goals

Sven Nilsen 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, a way to do lifetime checking on function arguments was discovered
  • A different approach to code organization was explored by adding the ability to dynamically load modules
  • For nice error handling, added option, result and ? operator
  • To test the design of the language, created a demo for interactive coding
  • Mutability check to improve readability
  • Short For loop to improve readability and performance
  • Mathematical loops and Unicode symbols to improve readability
  • Go-like coroutines to add multi-thread support
  • 4D vectors with unpack and swizzle to make 2D and 3D programming easier
  • Html hex colors to make copying colors from image editors possible
  • Optional type system to help scaling a project
  • Ad-hoc types for extra type safety
  • Current objects to improve prototyping and tailored environments
  • Macros for easier embedding with Rust
  • Secrets to automatically derive meaning from mathematical loops
  • Closures that can be printed out, use current objects and grab from closure environment
  • Type safety for secrets, easy load/save of Dyon data
  • Link loop for easier and faster code generation and templates
  • In-types for easy cross thread communication
  • Lazy invariants, simple refinement types and binary operator overloading

Main goals:

  • Integrate well with Rust
  • Flexible way of organizing code

Performance will be optimized for the cycle:

coding -> parsing -> running -> debugging -> coding

Sub goals:

  • Safety

Non-goals:

  • Rust equivalent performance
  • Replace Rust to build libraries
  • Interfacing with other languages than Rust

§License

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.

§Contribution

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.

Re-exports§

pub use ast::Lazy;
pub use runtime::Runtime;

Modules§

ast
Dyon Abstract Syntax Tree (AST).
embed
Traits for Dyon interop.
macros
Dyon macros.
runtime
Dyon runtime.
threading
Wrapper code for co-routines.

Macros§

dyon_fn
Used to declare an embedded/external function in Rust which can be called from Dyon.
dyon_fn_pop
This macro is used by some other Dyon macros.
dyon_macro_items
This macro is used by some other Dyon macros.
dyon_obj
Used to implement embed::PopVariable and embed::PushVariable for some object.
join
Joins thread.
spawn
Spawns new thread.

Structs§

Call
Used to call specific functions with arguments.
ClosureEnvironment
Stores closure environment.
Dfn
Stores preloaded function constraints. These are already checked.
Error
Stores Dyon errors.
FnBinOpRef
Used to store direct reference to external function.
FnReturnRef
Used to store direct reference to external function.
FnUnOpRef
Used to store direct reference to external function.
FnVoidRef
Used to store direct reference to external function that does not return anything.
Link
Stores a link structure.
Mat4
Wraps a 4D matrix for easier embedding with Dyon.
Module
Stores functions for a Dyon module.
Prelude
Stores a prelude, used to load standard intrinsics and type check new modules.
Thread
Stores a thread handle.
UnsafeRef
Prevents unsafe references from being accessed outside library.
Vec4
Wraps a 4D vector for easier embedding with Dyon.

Enums§

FnExt
Refers to an external function.
FnIndex
Refers to a function.
Lt
Argument lifetime constraint.
Type
Stores a Dyon type.
Variable
Dyon variable.

Constants§

CSIE
A common error message when the call stack is empty.
TINVOTS
A common error message when there is no value on the stack.

Statics§

LAZY_AND
Lazy invariant for &&.
LAZY_NO
Lazy invariant that no arguments have lazy invariants.
LAZY_OR
Lazy invariant for ||.
LAZY_UNWRAP_OR
Lazy invariant to unwrap first argument.

Functions§

error
Reports and error to standard output.
load
Loads source from file.
load_meta
Loads a source from meta data. Assumes the source passes the lifetime checker.
load_str
Loads a source from string.
run
Runs a program using a source file.
run_str
Runs a program from a string.

Type Aliases§

Array
Type alias for Dyon arrays.
LazyInvariant
Type alias for lazy invariants of external functions.
Object
Type alias for Dyon objects.
RustObject
Type alias for Rust objects.