AFAIK F# has these and that's about it
Microfeatures I'd like to see in more languages
281–290 of 539 posts
Re: Microfeatures I'd like to see in more languages
#282 thing.process() unless thing.cancelled()
thing.doOne() until thing.queueIsEmpty()
showAdminMenu() if user.isAdmin()
etcRe: Microfeatures I'd like to see in more languages
#283I really like swift's simple way of collapsing try catch blocks down to a simple value|nil result. let data = try? aFuncThatThrows() Sometimes I just don't care about the reason for the exception and just want to know if it succeeded or not
Re: Microfeatures I'd like to see in more languages
#284Re: Microfeatures I'd like to see in more languages
#285> Frink has special syntax for date values. You can write # 2001-08-12 # to mean the date 2001-08-12 Frink? Frink ? This Visual Basic erasure can not stand. The #-delimited date literal syntax has been found all over the VB family: Visual Basic, VBA, VBScript, and it persists to this day in Visual Basic .NET. Of course, being a VB syntax, it's completely cursed. You can put # 01/05/2023 # in a VB file, and what date…
Re: Microfeatures I'd like to see in more languages
#286Also, I wish the unary negation operator was more visually salient. `foo * -bar` is very different from `foo * bar`, but it's only a handful of pixels on the screen. I've thought about trying to render it as an em-dash or something. Didn't NASA lose a rocket over a spurious - sign?
Re: Microfeatures I'd like to see in more languages
#287Negative array subscripts. So a[-1] means the last element of an array, a[-2] means the second last, and so on.
Re: Microfeatures I'd like to see in more languages
#288Php supports kebab-case variables: ${"variable-name"}=123; Isnt it beautiful?
var `variable-name` = 123
`variable-name` = 456
Looks much cleaner to me.Re: Microfeatures I'd like to see in more languages
#289Earlier quoted context omitted.
and vice-versa Doesn't the reverse pollute the function namespace? If every obj.fun() can be written as fun(obj), doesn't that cause ambiguity with a previously imported global function fun()?
In rust you can do this but they are namespaced with the name of the struct. So you can do Object::fun(obj)
Re: Microfeatures I'd like to see in more languages
#290I want more implicit typing in typed languages. Quite often the compiler knows exactly what type a function will return, but I still need to write it there. Sometimes it’s easy („int“), but what about HashSet >> Typescript does it well. F# (completely statically typed) too…
Rust does a pretty decent job of this, particularly around functions that return collect(). But yeah, C++ has a ways to go on type inference.
The main case it doesn't handle is
for (auto i = 0; i
where obviously I want i to match the return type of foo.size(), so a size_t rather than an int.