I like this article but oh man dates just trigger me. Such a missed opportunity to use an unambiguous date example like 2001-08-13
Microfeatures I'd like to see in more languages
31–40 of 539 posts
Re: Microfeatures I'd like to see in more languages
#32> Instead of writing 10000500, you can write 10_000_500, or 1_00_00_500 if you’re Indian. I hate this so much. It means I can't grep for a constant.
You'll also be able to give these constants semantically significant names, and comment next to them providing derivations or citations. And of course, if it's a mistaken or outdated value, you can change it one place and apply it everywhere.
Consider that, if you were debugging a problem with this constant, and the problem was caused by someone having made a typo in one of it's usages (eg having typed 1000500 instead of 10000500, a mistake that's more difficult to make of you have better ways to format numbers [did you have to look back and forth to find the mistake? I did]) - your regex would fail to find it, even if there were no ambiguity about the format it was written in.
Re: Microfeatures I'd like to see in more languages
#33Earlier quoted context omitted.
How many languages support kebab case with any Unicode dash that isn't the ASCII one? :)
At the moment, the only one I know for sure is Agda. I suspect java would work as well, not sure about golang unicode var naming.
But then the spec[1] says that only code points characterised as "Letter", an underscore, or characterised as "Number, decimal digit" are valid.
Re: Microfeatures I'd like to see in more languages
#34> You can write # 2001-08-12 # to mean the date 2001-08-12, instead of writing something annoying like Date(2001, 8, 12) I like this article but oh man dates just trigger me. Such a missed opportunity to use an unambiguous date example like 2001-08-13
Re: Microfeatures I'd like to see in more languages
#35Re: Microfeatures I'd like to see in more languages
#36After having discovered Zig, I've been missing that feature in every other language.
Re: Microfeatures I'd like to see in more languages
#37I really liked the postfix and prefix notation in Mathematica. These three all mean the same: f[x] f@x x // f It matches the flow of thought more naturally when hammering out a couple of one-liners.
How is that third one readable at all? I’d assume it meant integer division.
Re: Microfeatures I'd like to see in more languages
#38Great, introduce slang to languages, what could go wrong?
Re: Microfeatures I'd like to see in more languages
#39Clojure’s loop expression hits this spot for me. It sets a recursion point to which you can jump using any logic inside the body you want, as long as it is from tail position. It’s like a while loop turned into an expression. I haven’t encountered any other way to write iterative expressions whose number of iterations isn’t known at the top (like map and reduce).
`unfold`, Rust's `loop`, generators, working tail recursion elimination (the lack of which loop/recur is a workaround for)
Re: Microfeatures I'd like to see in more languages
#40> Instead of writing 10000500, you can write 10_000_500, or 1_00_00_500
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/nume...
> Balanced string literals
https://hackage.haskell.org/package/raw-strings-qq-1.1/docs/...
> Generalized update syntax
Use Lens. `fileName %~ max 2`
> you can write the sequence 1, 2, … n-1 as 1..Yup. `[1,2..n-1]` There's far more to it, you have access almost a SQL-like sublanguage.
> Symbols
In Haskell you use hash has a prefix instead of colon.
Haskell sadly does not do automatic lifting, no extended parameter blocks, and no kebab-case.