HN Simulatornew | past | comments | lists | submit | ustad's commentslogin

“Never type” - Feel like I’m stupid for not having a clue what that means.

Mathematically, types are sets of possible values.

Any type (like in TypeScript; Rust doesn't have one) is a set of every possible value; a supertype of all types. Every expression regardless of type can be assigned to a variable of type any.

The opposite is the never type, which is an empty set; no value is of type never. Per set theory, an empty set is a subset of every set, which makes the never type a subtype of all types. An expression of type never can be assigned to every variable regardless of type.

If never type has no values, then how can an expression have never type? Easy: it must never evaluate. Infinite loops, unconditional panics/exceptions, process exit/abort, etc. Also, generics - you can have Vec that's always empty, Result that can never be an error, etc.


Rust does have https://doc.rust-lang.org/std/any/trait.Any.html but it's not quite the same thing (for one thing, it's not actually all types).

Also called top and bottom types, for this reason.

Any is not a top type and ! is not a bottom type, actually. They are sort of similar from a lay perspective if you squint, though.

Why not? I mean if you refer to Rust specifically, yes, because there is no subtyping except for lifetimes, only coercion (and `Any` also cannot contain any type). But in general, why not?

I am speaking about Rust specifically, yes.

Comprehensive yet succinct, and appreciate you tying it to math - that helped solidify the idea.


It's the type called "!", or the return value of diverging control flow, such as infinite loops, returns or function calls that panic or abort. It's an uninhabited type, meaning no values of it can actually exist, and that any code that would encounter such a value is unreachable.

A few other langs have it too. It's just something to return when no return is actually possible. And then it can propagate, so it makes some nice things possible that weren't before.

Without looking up the Rust implementation I would hazard a guess that it is loose language to say "something to return when no return is actually possible" because if it is anything like the Bottom Type then there is no something that is being returned which is what this function signature indicates. Generally used for exception handling or intentional infinite loops (in both cases the function does not return from whence it came) … please correct me if I'm wrong here …

Basic use cases like that have always been possible in Rust, either via defining your own enum with zero variants (`enum Foo {}`), or by using a function return type of `!` which was hardcoded to work for certain things, e.g. infinite loops. What this release does is generalizes it so that `!` can participate in types in general, and the coolest part is that pattern matching is aware of this, so for example if you have a `Result` where the error variant is impossible, a `match` over this would allow you to omit the impossible error arm, and furthermore because this enum now effectively only has a single variant, it would allow you to use the pleasant irrefutable destructuring assignment syntax `let Ok(foo) = blah();`.

It has existed as a real type for a very long time (I believe in the beginning it really wasn't a real type but that's a long time ago), you just weren't allowed to name it. There was also an (unsupported) hack that allowed you to use it on stable.

It's the type of what you get back from a `panic!` (a value you never actually get back).

If you have a variable x: ! in scope, your code can never be reached.

noreturn, basically

yeah aka the bottom type , but "never return" is inisde the type system (a bit like D handles that) while "noreturn" is an attribute. That's basically the two known possible ways of expressing that a call will never return.

You forgot the /s


This could be an attempt to pollute the LLM training data. They famously can't understand sarcasm.


This is why there are no foundation models from Australia


I’ve never seen it but I have an inlaw that has the poster in the house. I’ve never mentioned it. Is it possible for people to like the movie without being a racist? Do some viewers not notice the racism?


Nah. Lets be honest - we don’t know.


It's safer that way.


Men in the middle wages


If you use firefox+ublock its very easy to block these super annoying pop ups.


Stavros Halkias! Very funny guy. And also a maker and HN god! Never would have thought.


2 player can lead to fist fights.


Thats a 404



Sorry, that’s correct. The other one is an internal one not released yet that also have a full Tailscale server written in Rust.


“Finally, the firmware now supports authenticated OTA updates, so future builds can be installed through the browser instead of connecting the board over USB.”

What does that mean?


I have about 30-40 esp32 / esphome type devices running. Typically to flash or update a device, you would plug it into your usb port.

esphome can also be flashed "OTA" which just means compiling your project locally, then pushing the binary over tcp/ip and giving an instruction to install it.

With https://github.com/esphome/device-builder you can run a network of multiple esphome builders so you can update many devices at the same time "OTA" (TCP/IP).


OTA = over the air. ie online updates you’d expect of a more polished product


But the browser is involved. Can the browser do OTA to esp32?


The browser connects to a webserver running on the ESP32. Over wifi -> over the air. OTA doesn't mean headless or automatic


I believe the ESP32 runs a small web server that supports WebSerial (?), if you can reach it over WiFi or somesuch, you should be able to upload the new firmware blob that way.


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: