Search code examples
rascal

Are there constants for infinity?


I notice that Rascal supports big integers. But I cannot find constants for infinity. Do they exist? If not, I would suggest add them since the sometimes they are quite useful. Currently, my workaround is to define something like int pInf = 1024, but it may fail for extreme cases.


Solution

  • No support for infinity in Rascal.

    The "Rascal" way of dealing with such variability is to introduce an algebraic data-type, as in:

    data Arity = inf() | fixed(int size)
    

    Then you can use pattern matching or is or whatever to deal with the differences.

    if (arity is inf) {...}
    int foo(fixed(int size)) = ...; 
    int foo(inf()) = ...;