Live data from Hacker News

Microfeatures I'd like to see in more languages

buttondown.email

281–290 of 539 posts

Re: Microfeatures I'd like to see in more languages

#283

I 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

Rust does this too with `Result::ok`

Re: 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…

The cursed aspect that you mention is a mighty fine argument for why the article should indeed choose Frink as the language to steal from.

https://frinklang.org/#DateTimeHandling

Re: Microfeatures I'd like to see in more languages

#286
I might add kebab-case to my current language project. From all the code I've written, I only found a handful of - operators not surrounded by spaces, so that ambiguity wouldn't bite me often.

Also, 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

#289
post #103
post #42

Earlier 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)

You can also `use Object::*` to be able to do this without prefixing. Also, you can throw use statements into functions, so this is pretty useful in specific cases.

Re: Microfeatures I'd like to see in more languages

#290
post #77

I 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.

Between `auto` and `decltype(auto)` it mostly does what I want, although the 2nd syntax is frightful.

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.
Post reply on HN