19 karma · joined January 24, 2022
I'll add that inspiration for the article came about because It was striking to me how Bjarne's example which was suppose to show a better way to manage resources introduced so many issues. The blog post goes over those issues and talks about possible solutions, all of which aren't great. I think however these problems with exceptions don't manifest into bigger issues because programmers just kinda learn to avoid exceptions. So, the post was trying to go into why we avoid them.
The third problem (RAISI) is a C++ specific problem that Python doesn't have. Partly because in Python try/catch doesn't introduce a new scope and also partly because Python tends not to need a lot of RAII because of the nature of interpreted languages.
I found this video a fascinating take on comparing C++ to Python if you haven't seen it: https://www.youtube.com/watch?v=9ZxtaccqyWA
fn stackExample() void {
var some_cpp_type: c.SomeCppType = undefined;
c.some_cpp_type_ctor(&some_cpp_type);
defer c.some_cpp_type_dtor(&some_cpp_type);
// ...
}I sort of mentioned this in the blog but this is good clarification.
> if you want to pass a shared_ptr to Zig, you need to pass a pointer to the shared pointer
For lore, I believe this GitHub thread is where I first learned about the how types of the same size/alignment can still have different ABIs :) https://github.com/microsoft/win32metadata/issues/623#issuec...
In the Zig version did you use my zigwin32 project or did you go with something else? Also, how did you like the Zig build system vs rusts?
For these reasons, we don't allow vehicles that will unnecessarily compromise safety and/or make a lot of noise.
Of course the goal/intent I've written suffers from the same problem as the rules did, the definitions are ambiguous, but I think there's a distinction between capturing the spirit vs the letter of the law. It's a guide for why the rules exist and when they should or shouldn't be applied. It's not perfect, but, I think it's an improvement of just listing rules. If capturing/publishing the reasons for rules alongside the rules was normalized I wonder how different things could be?
The bigger issue D has with this example is that normal parameters are always runtime. If you wanted this to work in D you would need to implement 2 versions of "double", one that takes n as a template parameter and one that takes it as a runtime parameter. D keeps comptime and runtime parameters separate, making comptime-knowness a "parameter color" which in practice means having to implement things twice if you want it at comptime and often in different ways. There are some things that can work with both but it's small subset of both.