[OT] Move semantics in a nutshell
Timon Gehr
timon.gehr at gmx.ch
Sat Nov 8 11:00:25 UTC 2025
On 11/8/25 00:47, monkyyy wrote:
> On Friday, 7 November 2025 at 19:31:31 UTC, Sergey wrote:
>>
>
>> https://www.youtube.com/watch?v=Klq-sNxuP2g
>> invarients are super duper important
>> (ints just work tho)
>> some of the worse sorts of c++ complexity
>> rust being annoying
>
> What a very strong argument for never ever doing this, but strangely the
> author thinks this is all important
>
> Int "has the invariant" that its bits "represent" 0 from int.max, this
> is a perfect "bipart map" of the real hardware
>
> .... Or you can just say "Ints airnt stupid"
> ...
You don't have to share takes this nonsensical every time someone
overuses a word not defined on simple wikipedia. It's a choice.
> ---
>
> Theres is like 1 "invariant" anyone ever cares about "does it exist?",
"Does it exist?" is not an invariant, this is a predicate. "it exists"
is an invariant (or "if condition holds then it exists"), but what is
"it"? In practice, what is "it" is described by another invariant.
> why not just make a warper of slices to `length()=>data.ptr is null ?
> 0 : data.length`
> ...
"It's a slice" is an invariant I care about. And even if you don't tie
your invariants to data types, there is still an abundance of them, even
if you refuse to describe them in these terms. Programs simply don't
degrade gracefully under random bit flips in CPU registers, even if they
use only `int`s. The hardware design itself has invariants everywhere,
including within the implementation of the instructions that manipulate
integers.
> woaw so much safety
Unsafe C code, such as the linux kernel, is full of invariants. x)
In fact, the less safe your language is, the more you have to explicitly
think about invariants in order to write good programs. It's just more
likely that they remain arcane knowledge instead of being documented,
perhaps even within the type system.
More information about the Digitalmars-d
mailing list