Problem running code: "Name variable: used in process context"  

  RSS

lgasior
(@lgasior)
New Member
Joined:5 months  ago
Posts: 3
18/05/2018 10:12 am  

I'm trying to run example code from one of rholang videos:

new helloAgain in {

contract helloAgain(_) = {
new chan in {
chan!("Hello") |
for (text <- chan) {
text.display()
}
}
} |
helloAgain!(Nil)
}

running RChain Node 0.3.1 and calling `python RChain.py test.rho` yields:
`Error: coop.rchain.rholang.interpreter.NormalizerExceptions$UnexpectedProcContext: Name variable: text at 6:14 used in process context at 7:13`


ReplyQuote
lgasior
(@lgasior)
New Member
Joined:5 months  ago
Posts: 3
18/05/2018 10:19 am  

What a pity I cannot edit my post 🙁 Adding `@` at `(@text <- chan)`  seems to move it a bit further, after then it's failing with: `Exception in thread "grpc-default-executor-1" java.lang.Error: Attempted to print unknown Expr type`.

ps. I just noticed there's a separate rholang section, this post could be moved there


ReplyQuote
MichaelBirch
(@michaelbirch)
Member Moderator
Joined:8 months  ago
Posts: 41
18/05/2018 3:02 pm  

Rholang is a very new language and so constantly evolving. As a result, old examples typically do not work with the latest Rholang interpreter. It's important to remember that in the current Rholang you send processes and receive names. This is the source of the original error, you send the process "Hello", but receive the name @{"Hello"} and bind it to the variable `text`. By putting an `@text` instead you make a name pattern which represents a quoted process, therefore binding `text` as process variable.

The new error about unknown expressions is because you are using a method `.display()`. Methods are not supported in the 0.3 interpreter, but will likely be supported in the 0.4 interpreter. However, you can still complete your example because we now have special channels which have replaced the old `.display()` anyways. The line `@"stdout"!(text)` will do what you are expecting in that example. In addition there are the channels `@"stdoutAck"`, `@"stderr"` and `@"stderrAck"`with similar functionalities. You can find examples of their usage here.


ReplyQuote
lgasior
(@lgasior)
New Member
Joined:5 months  ago
Posts: 3
18/05/2018 4:28 pm  

Thanks Michael! "Rholang is a very new language and so constantly evolving" - that's also why it's interesting 😉 I'm curious to see what it will ultimately evolve into.


ReplyQuote
  
Working

Please Login or Register