Compiled Hello World

BAP Online Manuals : Bap Language Tutorial : Hello World Examples : Compiled Hello World
Previous: Interactive Hello World
Next: Remote Hello World

2.2.2. Compiled Hello World

We now will invoke the compiler to produce a compiled version of 'Hello World':

% *****************************************************
%		'hellow.bap': Hello World Compiler Example
% *****************************************************
MODULE hellow.
EXPORT hello_world.
PREDICATE hello_world.
hello_world:-
get_my_id(ProcessId),
write("Hello World, I am ",ProcessId,".\n").

Please invoke your favourite editor, type the program above into the file 'hellow.bap' in the 'program' directory and start the compiler . (In case that you don't want to type in the program please use the file 'hello.bap' provided in the 'program' directory.)

After a successful compilation please switch back to the shell or do a system restart, so that a shell appears. Type in the commands:

> load_all(hellow)
< ;
> hello_world
< Hello World, I am msg(1,5).
< ;

Note:

There may appear something different than 'msg(1,5)'. This term is the address of a process that may depend on the actual configuration of your system.

Explanation:

The first command ( load_all() ) loads the compiled code of the file 'hellow.lkd' onto the transputer network. The second command starts the execution of the 'hello_world()' predicate.


BAP Online Manuals : Bap Language Tutorial : Hello World Examples : Compiled Hello World
Previous: Interactive Hello World
Next: Remote Hello World