Rholang's type system  


Active Member
Joined:1 month  ago
Posts: 6
28/04/2018 3:20 am  

I started writing articles to introduce RChain/Rholang, here is the first one in Chinese.

I intend to write more but before that I need train myself to be very familiar with Rholang.One thing I am confused is its type system.

So, for primitive types (string/number/boolean/etc), they are all processes. But are they statically typed in compile time?

Suppose there is a contract which accepts one parameter , and the parameter should be a quoted process of number.

contract x(num) = { }

 Now if I send a string , x!("string"), to this contract, it does not generate any compiliation error.

Is Rholang static typed language?  If yes, how would the above code to be modified?

Spatial types

The grammar for spatial types is the grammar for processes extended by the following

<process> ::= "private"
    | "~" <process>
    | <process> "&&" <process>
    | <process> "||" <process>
    | "=" <process>

Also the rholang specification mentioned a few lines about spartial type. I want to know more but dont know where to start. The paper is obscure hard to understand as I am not a mathematician

Mike Stay
Member Moderator
Joined:2 months  ago
Posts: 13
01/05/2018 12:07 am  

Is Rholang static typed language?

The typechecker does not run statically yet, so at the moment it is dynamically typed.  We also do not yet have patterns for the collections of primitive types, so we can't even say num vs string yet.  That said, we can match on the structure of the AST, so in some ways it's much more powerful than many languages, but in other ways it's stupid.  The language is still very young.

the rholang specification mentioned a few lines about spartial type.

Spatial types are currently implemented as patterns in the `match` construct and in the patterns in `for`s and `contract`s.  For example, one can say

    for (@{"name": name, "age", age} <- y) { Q }

and it will only do Q if the message sent on y is a map with the given keys.



Please Login or Register