Skip to content

Instantly share code, notes, and snippets.

@bvssvni
Last active January 22, 2016 22:27
Show Gist options
  • Save bvssvni/c473c82242b1460a6741 to your computer and use it in GitHub Desktop.
Save bvssvni/c473c82242b1460a6741 to your computer and use it in GitHub Desktop.
working on a home made scripting language - name suggestions?
fn set_x(a: 'return, val: 'a) -> {
a.x = val
return val
}
fn main() {
y := {x: {0: 0}}
set_x(y, {0: 2}) // ERROR: Requires reference to variable
println(y)
}
@bvssvni
Copy link
Author

bvssvni commented Jan 18, 2016

Some info about the language (mix of Rust, Go and Javascript):

  • Just developed for fun right now
  • Using Piston-Meta for parsing, so people can change the syntax without recompiling
  • Goal: To develop a scripting language that is ordinary - specifically avoiding weird or fancy stuff
  • Does not use a garbage collector yet - uses lots of .clone() though and can unsafely return local variables inside objects
  • Might be able to use fn foo(a, b: 'a) { ... } for borrow checking to avoid unsafe code
  • If borrow checking is added, fn foo(a: 'return) -> { ... } means a is a reference that outlives the return value
  • Go like for i := 0; i < n; i += 1 { ... } loops and := for variable initialization and = for mutable assignment
  • Dynamically typed, similar to Javascript: Arrays [1, 2, 3] and objects {x: 0, y: 0} (however, = expects same type)
  • Function declaration similar to Rust fn foo() -> { ... }
  • Variable name shadowing like in Rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment