Schwift is an imperative programming language based on the fantastic show, Rick and Morty. It supports all of the classic language features required to elegantly build fantastic programs.
Schwift is a dynamically typed language:
>>> x squanch 10
>>> show me what you got x
10
>>> x squanch "Hello"
>>> show me what you got x
Hello
Schwift supports dynamically typed lists as a first-class type:
>>> x on a cob
>>> x assimilate 10
>>> x assimilate "hello"
>>> show me what you got x
[Int(10), Str("hello")]
Schwift has manual memory management through the flexable squanch
keyword:
>>> x squanch 10
>>> squanch 10
>>> show me what you got x
error: x is undefined
If you want your schwift programs to be blazingly fast ™, you really have to extend them with Rust functions. Your Rust code should look like this:
extern crate schwift;
use schwift::value::Value;
use schwift::error::{SwResult, ErrorKind};
use schwift::plugin_fn;
plugin_fn!(multiply_internal, multiply);
fn multiply_internal(args: &mut Vec<Value>) -> SwResult<Value> {
if let Value::Int(x) = args[0] {
if let Value::Int(y) = args[1] {
return Ok(Value::new(x * y));
}
}
Err(ErrorKind::UnexpectedType {
expected: Type::List,
actual: args[0].get_type(),
})
}
[package]
name = "got_schwifty"
version = "0.1.0"
authors = ["Nate Mara <[email protected]>"]
[dependencies]
schwift = "*"
[lib]
name = "gotshwifty"
crate-type = ["dylib"]
And your schwift should look like this:
microverse "./path/to/libgotschwifty.so" :<
multiply()
>:
x squanch multiply(10, 20)
show me what you got x
This program should print 200.