Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change stdout to result for exploredeploy #53

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
16 changes: 8 additions & 8 deletions 01-SendingAndStandardOut/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ There is a long-standing tradition in programming that your first program should
Make the program print "Rholang rocks!" instead of "Hello World".


## WTH is stdout?
## WTH is result?

![Channels are like mailboxes for sending messages](mailbox.png)

The heart of rholang is communicating on channels. Channels are communication lines that you use to send and receive messages. To send a message on a channel, you use the `!` character.

![Redo this diagram!](sendSyntax.png)

We created the channel `stdout` on the first line of the program with `new stdout`. You'll create lots of channels as you learn rholang. We also gave our channel a special power by including `(rho:io:stdout)`. More on that later, but for now just know that you need that part in parentheses to make text actually appear on the screen.
We created the channel `result` on the first line of the program with `new result`. You'll create lots of channels as you learn rholang. The first new channel defined will be returned as the result of an explore deploy. More on that later, but for now just know that you need that the first channel name will give you a result of an explore. For an actual deploy onto the blockchain the value retuned will be on a special deployId channel.


## Using other channels

![Sent messages wait to be received here in "message purgatory"... JK, it's called the "tuplespace"](mailboxes.png)

You can actually send messages on lots of channels, not just `stdout`. But unlike `stdout` they won't display on the screen because we won't add any special powers to them.
You can actually send messages on lots of channels, not just `result`. But unlike `result` they won't display on the screen because we won't add any special powers to them.

[tupleSpace.rho](tupleSpace.rho)

Expand Down Expand Up @@ -66,24 +66,24 @@ Print two messages, "Rick" and "Morty", on the screen in one program.

## Quiz

What will `stdout!("Programming!")` print to the screen?
What will `result!("Programming!")` print to the screen?
- [x] Programming!
- [ ] stdout!
- [ ] result!
- [ ] Nothing


What channel does `what!("Up")` send a message on?
- [ ] `Up`
- [x] `what`
- [ ] `what`
- [ ] `stdout`
- [ ] `result`


Which does rholang do first in
```
stdout!("Dogs")
result!("Dogs")
|
stdout!("Cats")
result!("Cats")
```
- [ ] prints "Dogs"
- [ ] prints "Cats"
Expand Down
4 changes: 2 additions & 2 deletions 01-SendingAndStandardOut/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Storage Contents:

## 小测试

`stdout!("Programming!")` 将在屏幕上输出什么?
`result!("Programming!")` 将在屏幕上输出什么?
- [x] Programming!
- [ ] stdout!
- [ ] result!
- [ ] Nothing


Expand Down
4 changes: 2 additions & 2 deletions 01-SendingAndStandardOut/README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ Storage Contents:

## Тест

Что выведет на экран фраза `stdout!("Programming!")` ?
Что выведет на экран фраза `result!("Programming!")` ?
- [x] Programming!
- [ ] stdout!
- [ ] result!
- [ ] Ничего


Expand Down
4 changes: 2 additions & 2 deletions 01-SendingAndStandardOut/hello.rho
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
new stdout(`rho:io:stdout`) in {
stdout!("Hello World!")
new result in {
result!("Hello World!")
}
4 changes: 2 additions & 2 deletions 01-SendingAndStandardOut/parallel.rho
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
new chan1, stdout(`rho:io:stdout`) in {
stdout!("I'm on the screen")
new result, chan1 in {
result!("I'm on the screen")
|
chan1!("I'm in the tuplespace")
}
2 changes: 1 addition & 1 deletion 02-Receiving/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BTW, lines that start with `//` are called comments. They're just there for huma

![Pizza shop can receive messages on its channel.](pizza.png)

The following code sends a message on a channel for a pizza shop and the pizza shop receives it. The pizza shop acknowledges receiving the message by printing to `stdout`.
The following code sends a message on a channel for a pizza shop and the pizza shop receives it. The pizza shop acknowledges receiving the message by printing to `result`.

[pizzaOrder](pizzaOrder.rho)

Expand Down
4 changes: 2 additions & 2 deletions 02-Receiving/coffeeShop.rho
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
new coffeeShop, stdout(`rho:io:stdout`) in {
new result, coffeeShop in {
contract coffeeShop(order) = {
stdout!("Coffee Order Received")
result!("Coffee Order Received")
}
|
coffeeShop!("one hot chocolate")
Expand Down
4 changes: 2 additions & 2 deletions 02-Receiving/persistentPizzaShop.rho
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
new pizzaShop, stdout(`rho:io:stdout`) in {
new result, pizzaShop in {
for (order <= pizzaShop) {
stdout!("Pizza Order Received")
result!("Pizza Order Received")
}
|
pizzaShop!("one hot chocolate")
Expand Down
4 changes: 2 additions & 2 deletions 02-Receiving/pizzaOrder.rho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
new pizzaShop, stdout(`rho:io:stdout`) in {
new result, pizzaShop in {
pizzaShop!("2 medium pies")
|
for(order <- pizzaShop){
stdout!("Order Received.")
result!("Order Received.")
}
}
8 changes: 4 additions & 4 deletions 03-TelephoneNamesAndProcesses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ As the message says, you learn most when you experiment. So be sure to change th

### Exercise

That telephone game was fun, but it's always better the have more players. Go ahead and add a third player called Charlie. Instead of printing to `stdout`, bob will send the message along to Charlie. Then Charlie will print it to the screen. The More the Merrier!
That telephone game was fun, but it's always better the have more players. Go ahead and add a third player called Charlie. Instead of printing to `result`, bob will send the message along to Charlie. Then Charlie will print it to the screen. The More the Merrier!



Expand All @@ -38,7 +38,7 @@ Did you notice the `*` in `bob!(*message)`? In rholang there are two kinds of th

A "process" is any piece of rholang code such as our telephone game, or our pizza shop order program. Processes can be big hundred-line programs or small on-liners. They can even be tiny pieces of code that are just values. Here are some example processes.

- `stdout!("Sup Rholang?")` A common send
- `result!("Sup Rholang?")` A common send
- `Nil` The smallest possible process. It literally means "do nothing".
- `for(msg <- phone){Nil}` A common receive that does nothing when a message arrives.
- `"Hello World"` Another small process that also does nothing. These are called "Ground Terms".
Expand Down Expand Up @@ -121,7 +121,7 @@ What is `@@Nil`?
- [ ] `@"BobsPhone"`
- [ ] `*"BobsPhone"`
- [ ] `@*"BobsPhone"`
- [ ] `stdout!("BobsPhone")`
- [ ] `result!("BobsPhone")`



Expand All @@ -131,4 +131,4 @@ What is `@@Nil`?

Instead of a linear telephone game where each player passes the message to the next, let's add a branch in the game. So now Bob will send to Charlie like before, but Bob will also send to Dawn.

Each branch can be as long as you want, but at the end of each branch, print the message to `stdout`.
Each branch can be as long as you want, but at the end of each branch, print the message to `result`.
4 changes: 2 additions & 2 deletions 03-TelephoneNamesAndProcesses/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

"processes"可以是rholang中任何一个代码片段,例如我们的传话筒游戏,或者是披萨店订单程序。“process”可以是上百行的大程序,也可以只有几行。它们甚至可以是用于表示值的代码。下面是一些“process”的例子。

- `stdout!("Sup Rholang?")` 一个常见的发送操作。
- `result!("Sup Rholang?")` 一个常见的发送操作。
- `Nil` 最小的“process”。如字面意思,它不做任何事。
- `for(msg <- @"phone"){Nil}` 一个常见的接收操作,在消息到达时它不会做任何事。
- `"Hello World"` 另一个不做任何事请的小“process”。被称为"基础术语"。
Expand Down Expand Up @@ -123,7 +123,7 @@ Aice通过`for(message <- @"Alice")`接收我们的消息,所以, `message`
- [ ] `@"BobsPhone"`
- [ ] `*"BobsPhone"`
- [ ] `@*BobsPhone`
- [ ] `stdout!("BobsPhone")`
- [ ] `result!("BobsPhone")`



Expand Down
4 changes: 2 additions & 2 deletions 03-TelephoneNamesAndProcesses/README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

"Процесс" -- любой кусок кода на ро. Например, наша игра в сломанный телефон или пиццерия из предыдущих уроков. Процессы могуть быть программами на сотни строк или кусочками на одну строчку. Они даже могут быть крошечными фрагментами кода, которые представляют собой значения. Вот примеры процессов:

- `stdout!("Sup Rholang?")` Обычная отправка
- `result!("Sup Rholang?")` Обычная отправка
- `Nil` Наименьший возможный процесс. Он буквально значит "ничего не делать".
- `for(msg <- @"phone"){Nil}` Обычное получение, которые ничего не делает, когда поступает сообщение.
- `"Hello World"` Ещё один маленький процесс, который ничего не делает. Такие процессы называются "базовыми выражениями" ("Ground Terms").
Expand Down Expand Up @@ -120,7 +120,7 @@ What is `@Nil`?
- [ ] `@"BobsPhone"`
- [ ] `*"BobsPhone"`
- [ ] `@*BobsPhone`
- [ ] `stdout!("BobsPhone")`
- [ ] `result!("BobsPhone")`



Expand Down
4 changes: 2 additions & 2 deletions 03-TelephoneNamesAndProcesses/telephone3.rho
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
new alice, bob, stdout(`rho:io:stdout`) in {
new result, alice, bob in {
// Start the game by sending a message to Alice
alice!("How to program: Change stuff and see what happens.")
|
Expand All @@ -14,6 +14,6 @@ new alice, bob, stdout(`rho:io:stdout`) in {
// Concurrently, Bob will listens for the message
for (message <- bob) {
// Bob is the last player, so he'll announce the message
stdout!(*message)
result!(*message)
}
}
6 changes: 3 additions & 3 deletions 04-PersistentSendAndPeek/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Confirm for yourself that the original send is still in the tuplespace.
### Exercise
Modify the above code so that a second pilot also receives the information. Still, the send persists.

By the way, did you notice that we don't need `new stdout(...) in {}` when we don't actually print anything to the screen `stdout`?
By the way, did you notice that we don't need `new result(...) in {}` when we don't actually print anything to the screen `result`?

How many comm events happen in `for (x <- y) {Nil} | y!!(Nil)`
- [x] `1`
Expand Down Expand Up @@ -55,13 +55,13 @@ One problem with the code above is that a forgetful pilot may not actually put t

![Peeking at a message allows you to read it without consuming it.](letterPeek.png)

Rholang will have a special syntax for this sort of thing eventually. It isn't available right now, but I'll show you the syntax just so you're ready. To "peek" at what's on a channel without consuming it, use the `<!` operator.
To "peek" at what's on a channel without consuming it, use the `<<-` operator.

[peek.rho](peek.rho)


Which syntax is used to peek at a message?
- [x] `for (x <! y){...}`
- [x] `for (x <<- y){...}`
- [ ] `for (x <= y){...}`
- [ ] `x!!(y)`

Expand Down
6 changes: 3 additions & 3 deletions 04-PersistentSendAndPeek/grandmaCheck.rho
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
new grandma, stdout(`rho:io:stdout`) in {
new result, grandma in {
// I send the message
grandma!("Meet at the mall at 4:00")
|
// I double check the message
for (msg <- grandma){
stdout!("Double checking the message")
result!("Double checking the message")
|
// Put a copy back on the channel for grandma
grandma!(*msg)
}
|
// Grandma receives it
for (msg <- grandma){
stdout!("I got your message")
result!("I got your message")
}
}
7 changes: 3 additions & 4 deletions 04-PersistentSendAndPeek/peek.rho
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// REMINDER: Peek is not yet implemented

new airportInfo, stdout(`rho:io:stdout`) in {
new result, airportInfo in {
// ATC sends the info
airportInfo!("No wind; Runway 11")
|

// Pilot receives the info
for (info <! airportInfo) {
stdout!(*info)
for (info <<- airportInfo) {
result!(*info)
}
|

Expand Down
4 changes: 2 additions & 2 deletions 04-PersistentSendAndPeek/persistentSend.rho
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
new airportInfo, stdout(`rho:io:stdout`) in {
new result, airportInfo in {
// ATC sends the info
airportInfo!!("No wind; Runway 11")
|
// Pilot receives the info
for (info <- airportInfo) {
stdout!(*info)
result!(*info)
}
}
4 changes: 2 additions & 2 deletions 04-PersistentSendAndPeek/putBack.rho
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
new airportInfo, stdout(`rho:io:stdout`) in {
new result, airportInfo in {
// ATC sends the info
airportInfo!("No wind; Runway 11")
|

// Pilot receives the info
for (info <- airportInfo) {
stdout!(*info)
result!(*info)
// TODO Pilot MUST put the info back
}
|
Expand Down
4 changes: 2 additions & 2 deletions 04-PersistentSendAndPeek/putBackAnswer.rho
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
new airportInfo, stdout(`rho:io:stdout`) in {
new result, airportInfo in {
// ATC sends the info
airportInfo!("No wind; Runway 11")
|

// Pilot receives the info
for (info <- airportInfo) {
stdout!(*info) |
result!(*info) |
airportInfo!(*info) // Putting the message back for other pilots
}
|
Expand Down
2 changes: 1 addition & 1 deletion 05-JoinOperator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Rholang has the join operator for exactly this situation. To perform a join, jus

```
for (p1Pushups <- player1; p2Pushups <- player2) {
stdout!("The winner is...")
result!("The winner is...")
}
```

Expand Down
4 changes: 2 additions & 2 deletions 05-JoinOperator/launch.rho
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
new aliceLaunch, bobLaunch, stdout(`rho:io:stdout`) in {
new result, aliceLaunch, bobLaunch in {
// Listen for both launch commands
for (x <- aliceLaunch; y <- bobLaunch){
stdout!("Launching the rocket")
result!("Launching the rocket")
}
|
// When ready, Engineers send their commands
Expand Down
4 changes: 2 additions & 2 deletions 05-JoinOperator/launchBad.rho
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// REMINDER: This is the BAD way to solve the problem.

new aliceLaunch, bobLaunch, stdout(`rho:io:stdout`) in {
new result, aliceLaunch, bobLaunch in {

// Listen for Alice's then Bob's launch commands
for (x <- aliceLaunch){
for (y <- bobLaunch){
stdout!("Launching the rocket")
result!("Launching the rocket")
}
}
|
Expand Down
6 changes: 3 additions & 3 deletions 05-JoinOperator/patienceSolution.rho
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
new p1, p2, stdout(`rho:io:stdout`) in {
new result, p1, p2 in {
// Send messages like in both orders
p1!("Send any message") |
p2!("Hope I win") |

// When Player one wins
for (m2 <- p2){
for (m1 <- p1){
stdout!("Player one wins!")
result!("Player one wins!")
}
}
|

// When player two wins
for (m1 <- p1){
for (m2 <- p2){
stdout!("Player two wins!")
result!("Player two wins!")
}
}
}
Loading