Interval comparison operator for free!


If you had used Python before, you might have encountered a syntax sugar so called the Interval Comparison Operator, which is very convenient for checking if an integer is within a specific range.
For example,
if 80 <= grade <= 100:
print("You got A!")
print("Sorry, not A ...")
This is one of the nicest feature that Python has, however, it is not possible to be implemented in other language without performing some macro magic or modifying the internal parser.
But guess what? You can have that for free in Keli!
Because those operators can be defined as usual functions, as follows:
// Definition
(a Int).<=(b Int)<=(c Int) =
// Usage
= 80.<=(90)<=(100)
Moreover, it also works with Keli's Intellisense!

How is this possible?

This is possible because Keli supports the following features:
  1. 1.
    Keyword message syntax (like Smalltalk)
  2. 2.
    Function name can be any combination of operators


Of course, there are still a lot of other domain-specific operators or functions that can be defined easily in Keli. Hope you like this article, and is able to leverage the power of Keli to create your own domain-specific language(DSL) without hassle.