3 ms·
Would love a programming language where optional pre- and post-invariants were a first-class language feature. So each line could be: <pre-invariants> | <lin
by pizza 5y ago
Would love a programming language where optional pre- and post-invariants were a first-class language feature. So each line could be:
<pre-invariants> | <line of code> | <post-invariants>.
Then just let the compiler figure out the optimal ordering of things, figure out which things can be async automatically, and also perhaps this could be a built-in IDE static analysis tool to help catch logical errors earlier ¯\_(ツ)_/¯
- jerf 5y agoYou can get something like that in Haskell. Functions are piles of statements that you can generally write in any order, and the compiler will deal with the resolution. You don't see this effect very strongly in Haskell though because you generally end up with small functions that don't have that many statements anyhow. (If one is sort of vaguely familiar with Haskell and thinking "what about do notation?" (or, less correctly but to the same point, "what about monads?") the answer is that do notation is a syntax sugar for introducing functions in a slightly different manner, using "<-" and some syntax transformations, so "do notation" is not a function but a function per <- symbol. Do notation affords tons of very small functions.) "figure out which things can be async automatically" If you want this, learn Go or Erlang (or Haskell). Personally I find having to manually label and deal with sync vs. "async" functions intolerable, but, fortunately, I don't have to. At the very least, though, I'd like a type system to help me out. This is something any type system can provide a lot of help with very easily, even sticking with manual async annotation. Getting a compile time error for sticking a promise for an int into an int would help keep a lot of this straight.