25 karma · joined October 12, 2019
Moc just adds some more generated code next to you valid C++ code, generally in a new translation unit. That generated code is just boiler plate which you could write by hand if you wanted. In a sense this is what verdigris does: it provides macros that makes makes it easier to "write it by hand" (the W_OBJECT_IMPL macro somehow expends to the code generated by moc)
It is soon 2020, there is no reasons to use C in new code. Because of security and also convenience.
Maybe it is a nice mental exercise (also try brainfuck and malbolge), but not something for production.
There are plenty of programs that have bugs.
Programmers who exploit undefined behavior on purpose are reckless.
Why is that? I would intuitively think it is the other way. (Is a malloc/free pair not cheaper than an allocation on the GC heap + collecting its garbages?)
For example, no need to understand the magic behind the 'quote!' or the #[async_trait] macros to use them.
Although in this case, I guess this is probably fine since the non-atomic read can't race with a write.
Can't you get some values "out of thin air" (partial updates of some bits.) Or some intermediate values?
(For example, can the compiler decide to use this memory location to store some unrelated temporary result, as it knows it will erase it soon with a final value and that no other threads is supposed to access this)
https://code.woboq.org/qt5/qtbase/src/corelib/global/qglobal...
(Ah no..., wrong thread. This is actually about C. /s)
About the copy/paste of protobuf files, it works but makes it more difficult to keep them in sync.
And I did not say you need a single repo. I'm saying the stated disadvantages of multi repo are real.
See "less is exponentially more".
The same way some electric bikes are restricted to a given speed to keep their user safe. Some people call it "crippled", while some other call it "simple and safe to use".
It is a compiler error to use the value after it was moved. And the compiler error is quite explicit about how to solve it
For example you can explicitly clone
let y = add(x.clone());
let z = add(x);