Hello World
Here is the "hello world" program in Trylon. It can also be found in the "tests" directory of the distribution. Here are the contents of the "main" file:
trylon hello-world
main: args
print-line: "Hello world!"
return 0
The "trylon" line is not necessary, but it may help your editor highlight syntax. Anything after the word "trylon" on that line is usually ignored, but often the name of the class defined in the file is put there. But we're looking at the one case where it makes a difference: in your main "main" file, the word after "trylon" is used as the name of the resulting binary, if it isn't specified elsewhere.
The rest of the file declares a function named "main:". The "main:" function is, as one might expect, the main function of the program. Every Trylon program needs to have one.
To build this program, make a directory for your program, and put the code into a file named "main" in that directory:
Go into that directory and type "trylon". The code will be compiled into a program that's ready to run:
Larger Programs
If you have more than one class in your program, you'll normally want each class to have its own file. These can go directly in your program's directory:
my-program/
main
CodeView
HTMLView
Window
But you can keep your top-level directory cleaner by putting your code into a "sources" directory:
my-program/
my-program
sources/
main
CodeView
HTMLView
Window
ReadMe
A more complex example, showing how some classes are used as namespaces containing other classes:
my-program/
my-program
sources/
main
CodeView/
HTMLView/
main
Document
Element
Node
Text
Build Settings
Your program's directory may also contain a "build-settings" file. Here's an example:
program = "my-program"
debugger = true
support-perform = true
c-flags += "-O1"
c-flags += "-I/usr/include/cairo"
link-flags += "-lcairo"
c-sources-dir = "C-sources"
use-clang = true
if use-clang
c-compiler = "clang"
linker = "clang"
The settings can also be modified by a "build-settings.local" file. "build-settings" would be distributed with the program (checked into the Git repository, included in the tarball, etc.), but "build-settings.local" would allow local (possibly temporary) changes like enabling debugging.
my-program/
.gitignore
build-settings
build-settings.local
my-program
sources/