> 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.
If you have constants repeated throughout the codebase, you can pull them into a constants file, and then you can go to that file, navigate to the definition of interest, and use your IDE of choice to find usages. 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 i…
Microfeatures I'd like to see in more languages
51–60 of 539 posts
Re: Microfeatures I'd like to see in more languages
#52I love all the sugar of Kotlin, but there is one thing I miss, and it is the indexing of arrays of Python when pulling out part of an array.
arrayOf(1, 2, 3) - why not [1,2,3]?
emptyArray() - why not []?
mapOf("key" to "value") - why not {key => value}?
These are all solved problems. Why would they make up some harshly suboptimal syntax?
Re: Microfeatures I'd like to see in more languages
#53Earlier quoted context omitted.
Tail call optimization can get you that, too. If you've written Scheme and/or gone through SICP you might be familiar with this: you write a recursive function, with the recursive function call as the last thing the function does ('tail-recursion'), and the compiler/runtime is able to optimize those recursive calls out rather than consuming one stack frame of space per call ('tail call optimization'). Clojure has loo…
Interestingly, I almost prefer Clojure's `recur` semantically. Means you don't have to change the function name twice if you rename it, and it's hard to miss that you're recursing.
Re: Microfeatures I'd like to see in more languages
#54Re: Microfeatures I'd like to see in more languages
#55I 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
#56> 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.
1_?0_?00_?0_?500 yes it sucks
Re: Microfeatures I'd like to see in more languages
#57I have long wondered why Ruby's symbols aren't in every language.
Re: Microfeatures I'd like to see in more languages
#58Re: Microfeatures I'd like to see in more languages
#59Comptime. After having discovered Zig, I've been missing that feature in every other language.
Re: Microfeatures I'd like to see in more languages
#60> Most languages have multiline literals, but what makes the Lua version great is that the beginning and ending marks are different characters. This solves the infuriating “unnestable quotes” problem string literals have, and you don’t have to escape all your literal \s.
That paragraph also uses “nestable marks”.