The structure of a Red program

Until now, we have mostly used snippets of code, but a complete Red program starts with a Red [] block, called its header. If this is not present, the compilation stops immediately with the following message:

*** Syntax Error: Invalid Red program

Why is it needed? It must be there to signal that the file contains a script and not just random text; in fact, the .red extension is not at all needed for the compiler to work.

An empty header, such as the one we used, is not usually a good idea. In fact, the header is an information block that can contain all kinds of (meta)-info and documentation about the program, in the form of a series of pairs enclosed between rectangular brackets [ ]:

Red [ Name-Of-Info: "Value ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.