Skip to content

Latest commit

 

History

History
93 lines (78 loc) · 1.93 KB

hello.md

File metadata and controls

93 lines (78 loc) · 1.93 KB

Let us program our first "hello world!" example.

You will need to have one of the frameworks up and running. If not already done, go to the main page of pSpaces, choose a framework and follow the instructions to install it.

We will now create a simple program that illustrates the most basic features of spaces in different languages. The complete code of the example in each of the languages can be found here:

We will go through it step by step.

1. Create a space named inbox

Go

inbox := NewSpace("space")

C#

SequentialSpace inbox = new SequentialSpace();

Java

Space inbox = new SequentialSpace();

Swift

let inbox = TupleSpace(TupleList())

2. Put a simple tuple in the space

Go

inbox.Put("Hello world!")

C#

inbox.Put("Hello world!");

Java

inbox.put("Hellow world!");

Swift

_ = inbox.put(["Hello World!"])

3. Retrieve the tuple from the space

Go

var message string
t, _ := inbox.Get(&message)

C#

ITuple message = inbox.Get(typeof(string));

Java

Object[] tuple = inbox.get(new FormalField(String.class())

Swift

let tuple = inbox.get([FormalTemplateField(String.self)])

4. Print the message

Go

fmt.Println((t.GetFieldAt(0)).(string))

C#

Console.WriteLine(tuple);

Java

System.out.println(tuple[0]);

Swift

print(tuple)

If you got it, you are now ready for more examples :)