Comment by miniBill

3 days ago

Very cool language. The standard library looks mostly sane, although it does have `def get(i: Int32, a: Array[a, r]): a \ r` which means that it must have some kind of runtime exception system. Not my cup of tea, but an understandable tradeoff

Just looking at the language myself, but it seems that it treats out-of-bounds array access as a non-recoverable bug and panics [1, 2], whilst map access returns Option [3]. Exceptions are a language construct only to enable Java compatibility and not recommended otherwise [4], but that's not to say you couldn't implement your own try/catch using the effect system. `r` is a region variable as the sibling comment says.

[1] https://doc.flix.dev/chains-and-vectors.html#vectors

[2] https://flix.dev/principles/ See also "Bugs are not recoverable errors"

[3] https://api.flix.dev/Map.html#def-get

[4] https://doc.flix.dev/exceptions.html

  • I agree with OP that this seems a little unfortunate, even though it's pretty par for the course.

    "Bugs are not recoverable errors" is such a fuzzy idea. On the one hand, indexing an array with an out-of-bounds integer could just be considered a program bug. On the other, the point of making the indexing operation return an optional value is to force the program to handle that scenario, preventing it from being a bug. One of the examples they give of a "recoverable error" is illegal user input, but in the case of "the user enters an index and it might be invalid", the language does nothing to keep the recoverable error from turning into an unrecoverable program bug.

no, that's a region variable if i understand correctly, so closer to a rust lifetime

  • It is, but your reply seems like a non-sequitur. The point OP was making was that it doesn't return an Option or Maybe or anything like that, meaning that there's a failure case untracked by the type system.