First Procedure
Write and format your first Technique program
The simplest Technique is a single step:
1. Say hello to everyone.
We can embellish this with further text content. Wrapping on to a second line is fine.
1. Attempt to say hello to everyone in the room and
totally fail to get on with any of them.
Of course now we need to do something about the situation that this first step has created:
1. Attempt to say hello to everyone in the room and
totally fail to get on with any of them.
2. Offer to make tea.
Now we're getting somewhere!
A number of steps listed by themselves are perfectly valid Technique. Really! But sometimes we want to refer to these steps from elsewhere, or add a title, description, or other details. If we add a name to the document as a label this becomes a procedure:
greeting :
1. Attempt to say hello to everyone in the room and
totally fail to get on with any of them.
2. Offer to make tea.
The procedure declaration is an identifier and a colon. Later on we'll learn
about adding a signature to optionally define any inputs the procedure
requires and the type of whatever result it provides, but a name and : is
sufficient to declare a procedure.
Check the syntax
If you put this last version into a file called Hello.tq you can then run
the compiler on it. First you can run the check command to make sure it
parses correctly:
$ technique check Hello.tq
Ok
$
Code formatting
The Technique parser is remarkably whitespace agnostic. We ignore leading and trailing whitespace as much as possible. But there is a code formatter, which will tidy your document to the canonical layout that will best represents the nesting of the code and your intent as the author.
$ technique format Hello.tq
greeting :
1. Attempt to say hello to everyone in the room and totally fail to get
on with any of them.
2. Offer to make tea.
$
This will format the document and syntax highlight the output in your terminal console. If you redirect to a file then it'll be plain unhighlighted text
$ technique format Hello.tq > Hello2.tq
$ cat Hello2.tq
greeting :
1. Attempt to say hello to everyone in the room and totally fail to get
on with any of them.
2. Offer to make tea.
$
You may not have noticed, but it re-wrapped the content of step 1. to the width of a standard terminal and with the correct hanging indent. There's an option to specify a different wrap width if you require.
Obviously renaming files manually would be tedious, but in editors with support for the Technique language you can code format the document in-place with "Format Buffer" or similar.