Tuesday, November 16, 2010

Hello, World!

Every programming language tutorial starts off with a "hello world" example, so Sizzle should be no different. While Sizzle typically sends its output to large files or a database, printing output to the screen is necessary for any programming language, particularly those that have no debugger.

In Sizzle, it's as easy as:

emit stdout <- "Hello World!";

In a similar vein, printing out error text goes like this:

emit stderr <- "Something bad happened!";

These work because, behind the scenes, Sizzle predefines special aggregators called 'stdout' and 'stderr' that just echo anything emitted to them out to the terminal:

stdout: table collection of s: string file("/dev/stdout") format("%s\n", s);
stderr: table collection of s: string file("/dev/stderr") format("%s\n", s);

As a side note, when running under Windows, Sizzle uses synthetic equivalents to '/dev/stdout' and '/dev/stderr', so this works under every popular operating system.

No comments:

Post a Comment