Hacker News new | ask | show | jobs
by nixpulvis 2291 days ago
I'm very aware of set builder notation, and also not a fan. I mean it beats a lot of other things mathematicians were probably doing before they agreed to it, but it's still not ideal in my eyes.

My example (formatted again below), is probably an interesting middle ground, because both the left and right are only mildly interesting. While most often (not always) in math I've seen the right be "trivial".

    trivial right: { 2x : x ∈ ℝ }
    mildly interesting right: { 2x : x ∈ [1,10) }
    complex right: { 2x : x ∈ [0, ∞].filter(...) }
In the top two cases, things aren't so bad. But as we digress to the third case I fear we'd be better of like:

    [0, ∞].filter(...).map(|x| 2x)
This is generally how I'd solve the issue. I've made a point of avoiding talking about nested array comprehensions, since these get completely impossible to reason about statically for me.

EDIT: Just because I' on a bit of a rant ATM, I might as well complete it...

In Rust we also have where clauses, however you still must at least introduce the name up front. For example:

    fn foo<A>(..., a: A, ...) where A: ...
This solves the problem of name resolution in my head while I try and read this function, since there's always a namespace you're operating within. Without the leading `<A>` I'd be left wondering WTF `a: A` means.