Skip to content

nh3dev/sharc

Repository files navigation

This project is now under the Free Ammonia Foundation :0
You can read more on our website: https://nh3.dev/projects/shard

Contributing Checklist

Examples

let x = 5;
let addx = |y| x + y;
add(10)
let printf_int = extern "printf" |fmt: raw &[u8], i: i32|: i32;
printf_int(c"hello %d\n", 5 + 10);
let average = |nums: &[u32]|: u32 {
	let sum = loop |sum = 0, i = 0| {
		if i == a.len => break sum;
		(sum + a[i], i + 1)
	};
	sum / a.len
};

average(&[1, 2, 3, 4, 5]) // => 3
let printf_int = extern "printf" |fmt: raw &[u8], i: i32|: i32;
let<T> malloc = extern "malloc" |size: usize|: raw &mut T;
let<T> free = extern "free" |ptr: raw &mut T|;

let Box = |t: type| raw &mut t;

let<T> box = |v: T|: Box(T) {
	let ptr = malloc(core::tyinfo(T).size);
	*ptr = v;
	Box(T)(ptr)
};

impl<T> Deref<&T> |Box(ptr): &Box(T)| ptr;

impl<T> Drop |Box(ptr): Box(T)| {
	Drop(*ptr);
	free(ptr);
};

let x: Box(i32) = box(5);
printf_int(c"%d\n", *x);
Drop(x);

TODOS

  • fix debug formatting for ast/hir to do proper indentation
  • get the website back up
    • move shard to faf (also make a faf org)??
    • update sherbert with new docs
    • sherbert fix syntax highlighting (prob get docs first)
  • diff syntax for < since that conflicts with type generics Foo<Bar>
  • define move semantics. what's copy by default?
  • bully @interacsion into either making a borrow checker or shutting up about it :) (preferably option b)
  • do actual trait resolution
  • integrate core traits as operator overloads
  • draft up shard docs:
    • basics + typing
    • core lib
  • update nightly version to one with good features/stability
  • [~] fix the bump allocator
    • miri error (rust bs semantics are driving me crazy)
    • possible double free on panic? (needs investigation)

About

Shard: a functional flavoured imperative language

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages