Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

The purpose of this page is to capture proposals of syntactic sugaring to benefit users of Rholang and to track discussion and decision-making related to these proposals.

...

ProposalDiscussionDecision

let

PLet. Proc2 ::= "let" [Binding] "in" "{" Proc3 "}";

BindingProcToPat. Binding ::= [Name] NameRemainder "<-" Proc3 ;

prototyped in PR #2055

see also RCHAIN-2641

The delimiter shown is ←; should it be =?


lambda

@ListOps!("foreach", 
          [1,2,3],
          (x, ret) => {ret!(x+1)},
          *retCh)

...would be desugared to:

new lambda1 in {
contract lambda1(x, ret) = { ret! (x+1)} |
@ListOps!("foreach",
          [1,2,3],
          lambda1,
          *retCh)
}

The desugared version is what one has to write anyway in order to use tools like ListOps.

The expressiveness of Rholang will be hugely improved.


"contract methods" (technically they are not methods but I have no idea how to call them (big grin))

contract channel.methodName(a, b, c) | channel.methodName!(P, Q, R)

will translate to:

contract channel(@"methodName", a, b, c) | channel!("methodName", P, Q, R)

which translates to:

for (@"methodName", a, b, c <= channel)


Could make the code more readable and also friendlier to OOP devs

contract varargs

contract myContract!(arg1, arg2, rest...) = { ... }

This would work nice with a tuple & list expansion
@myChannel ! (+(1,2,3)) |
@myChannel ! (+[4,5,6])

...would be desugared to

@myChannel !(1,2,3) |
@myChannel !(4,5,6)

Such a syntax feature would allow us to write multi-arity contracts easier.

Also we could write decorator contracts that receive a message with any structure, do some work and then forward the original message to a lower level


integrate registry dependency lookup with current functionality of new operator
new 

  MakeMint(`rho:id:exunyijimapk7z43g3bbr69awqdz54kyroj9q43jgu3dh567fxsftx`) in ...

...would desugar to 
new MakeMintCh in {
rl!(`rho:id:exunyijimapk7z43g3bbr69awqdz54kyroj9q43jgu3dh567fxsftx`, *MakeMintCh) | 

for(@(_, MakeMint) <- MakeMintCh) {

...

}

}


Any nontrivial contract startw with setting up the dependencies like this and it looks pretty bad
rl!(`rho:id:exunyijimapk7z43g3bbr69awqdz54kyroj9q43jgu3dh567fxsftx`, *MakeMintCh) |
rl!(`rho:id:9dsr55z1js13x346yhhecx66ns486i3yqf6jafrd9p9hdrrbxjqmyu`, *LockboxCh) |
rl!(`rho:id:j6trahbxycumerwpr5qype7j43b7eqh8auebwsa9nn68if47gswh73`, *EitherCh) |
for(@(_, MakeMint) <- MakeMintCh; @(_, Lockbox) <- LockboxCh; @(_, Either) <- EitherCh) {

...

}

For this we will have to make the registry lookup as a special case of system processes but since it's used everywhere I don't see that as being a problem.


ch1 ! ("someMethod", ←ch2, ← ch3)

...would desugar to 

for( x ← ch2, y ← ch3) { 

   ch1 ! ( "someMethod", x , y )

}



ch1#method ! (arg1, arg2,...)

...would desugar to

ch1 !  ( "method", arg1, arg2,...)

new x("rho:id:aaa") in { 

}

desugars to 

new ch, registryLookup(`rho:registry:lookup`) in {

  registryLookup!(`rho:id:aaa`, *ch) |

   for (x ← ch) {

      ...

  }

}



Jira Legacy
serverSystem JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId50130123-f232-3df4-bccb-c16e7d83cd3e
keyRCHAIN-2641


 

Jira Legacy
serverSystem JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId50130123-f232-3df4-bccb-c16e7d83cd3e
keyRCHAIN-2644



Jira Legacy
serverSystem JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId50130123-f232-3df4-bccb-c16e7d83cd3e
keyRCHAIN-2647


 
Jira Legacy
serverSystem JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId50130123-f232-3df4-bccb-c16e7d83cd3e
keyRCHAIN-2713


Mike stay's Rholang sugaring scratch pad

...