Hello, World! in Alef

Example for versions Alef (Plan 9, edition 2)

This example illustrates the usage of channels and processes. The main process creates a channel which transmits string addresses. After this it starts a child process with channel argument, feeds message address to the channel and terminates. The second process waits for the message, prints it and terminates as well.

#include	<alef.h>

void
receive(chan(byte*) c)
{
	byte *s;
	s = <-c;
	print("%s\n", s);
	terminate(nil);
}

void
main(void)
{
	chan(byte*) c;
	alloc c;
	proc receive(c);
	c <-= "Hello, World!";
	terminate(nil);
}