0

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
Tim
  • 221
  • 3
  • 12

1 Answers1

1

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.

Paul Klint
  • 1,418
  • 7
  • 12
  • I will use it as a "normal" function then. Some languages parse functions starting with "symbols" (!@#$%^&*) as also being usable as infix. Or use constructs like placing a function between backticks (\`) as infix: `first \`tstEq\` second` – Tim May 24 '16 at 12:56