19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

component HelloWorld<br />

export Executable<br />

run(args) = print “Hello, world!”<br />

end<br />

We can compile this program, by issuing the command “fortress compile” on it:<br />

fortress compile HelloWorld.fss<br />

As a result of this command, a component named “HelloWorld” is stored in the resident fortress. <strong>The</strong> name<br />

of this component is provided by the enclosing component declaration surrounding the code. If there is no<br />

enclosing component declaration, then the contents of the file are understood to belong to a single component<br />

whose name is that of the file it is stored in, minus its suffix. For example, suppose we write the following<br />

program in a source file named “HelloWorld2.fss”:<br />

export Executable<br />

run(args) = print “Hi, it’s me again!”<br />

When we compile this file:<br />

fortress compile HelloWorld2.fss<br />

the result is that a new component with the name HelloWorld2 is stored in the resident fortress. Once this<br />

component is compiled, we can execute it by issuing the following command:<br />

fortress run HelloWorld2<br />

In a script file, there must be at most one component declaration. In a compiled file, multiple component declarations<br />

may be included. For example, we could write the following file HelloWorld3.fss:<br />

component HelloWorld<br />

export Executable<br />

run(args) = print “Hello, world!”<br />

end<br />

component HelloWorld2<br />

export Executable<br />

run(args) = print “Hi, it’s me again!”<br />

end<br />

When we compile this file, the result is that both the components HelloWorld and HelloWorld2 are stored in the<br />

resident fortress.<br />

If a fortress already contains a component with the same name as a newly installed component, the new component<br />

shadows the old one. For example, if we first compile the source file HelloWorld3.fss above and then compile the<br />

following file HelloWorld4.fss:<br />

component HelloWorld<br />

export Executable<br />

run(args) = print “I didn’t expect that!”<br />

end<br />

then executing the component HelloWorld on our fortress will result in printing of the following text:<br />

I didn’t expect that!<br />

17

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!