c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Extend untyped list and make it into an anonymous struct

Open lerno opened this issue 3 years ago • 0 comments

The idea is that such a struct may be converted into an array so this works.

tlocal char[] context_user = "safe";

macro long perform(task)
{
	io::printf("%s: %s\n", context_user, task);
	return task.len;
}

macro @with_mode(char[] user, #action, arg)
{
	@scope(context_user)
	{
		return #action(arg);
	};
}

fn ulong tester()
{
	ulong a = @with_mode("faster", perform, "reliable");
	return a;
}

extern fn void printf(char*, ...);
fn void main()
{
	long result = perform("something!");

	result += @with_mode("faster", perform, "reliable");
	result += tester();
    result += perform( {"again", "more"});
    result += perform(int[<2>] { 56, 99 });
	io::printf("Result: %d\n", result);
}

lerno avatar Jul 20 '22 12:07 lerno