Search code examples
rascal

Is it possible to define your own operators in Rascal?


I'm writing some test helper functions to make the output more sensible:

bool tstEq(first, second) {
  if(first == second) 
    return true; 
  else {
    println("<first> was not equal to <second>");
    return false;
  }
}

Is it possible to do something like this?

bool ===(first, second) = tstEq(first, second);

usage:

test bool myTest() = 1 === 2

Which would result in something like:

rascal>:test
1 was not equal to 2
bool: false

Solution

  • A short answer: no. I fully agree that this can be convenient (but may also lead to less readable code).

    Given the large list of topics we want to address first, it is unlike that such a feature will come to Rascal in the near future.