class odd {...};
class even {...};
std::variant<odd, even> p(int a) {
if (a&1) return odd{a};
else return even{a};
}
Now which of `even` or `odd` you get is based on the value of `a`.489 karma · joined July 9, 2007
class odd {...};
class even {...};
std::variant<odd, even> p(int a) {
if (a&1) return odd{a};
else return even{a};
}
Now which of `even` or `odd` you get is based on the value of `a`. #! /bin/bash
cat /dev/urandom | base64 --wrap ${1:-"10"} | head -n 1
Defaults to 10 character passwords, but you can put bigger numbers as the first argument. I don't think the `base64` command is on the Mac, so probably won't work there.I really wanted to show that core part of a programming language can be quite simple and nothing to be afraid of so everything else was subservient to getting that across :-)
I expect we'll extend use of this sort of mechanism much further the more people understand it.
I'll watch that video, sounds interesting. A company I worked for nearly ended up getting a Symbolics LISP machine for CGI in the early 90s. Would have been pretty sweet I think.
Adding a garbage collector would make code more complex, not simpler, as it would break RAII. I spend a lot more time dealing with memory and resource allocation issues in GC languages than I do in C++.
In languages like Python we have to use `with`, and this is harder to use in the client code, and the class is much harder to write, than anything in C++ where we just add a destructor to clean up.
std::vector<char> data(10 << 20);
std::ifstream("/dev/urandom", std::ios::binary).read(data.data(), data.size());
The above code can never leak (either memory or file handles) under any circumstances and the implementations of the types involved push zero overhead/boilerplate on me as a user of them.I think if you want to reduce complexity of C the place that everybody else is looking is at how to allow opting in and out of legacy support.
This is exactly what the report says they did. The original post may exist on Twitter, but the conversation that happened on Facebook does not.
I just checked my feed, and my Twitter posts do seem to still be on my FB profile, at least when I look at it.
It's really incomplete, and I have had hardly any time to work on it over the many years that it's been around, but the general idea is to type construction to determine the aspects that a scene actually uses and let the compiler sort out what to do about it.
For example, the depth count attached to a ray doesn't appear until it hits a reflective surface so there is no overhead if the scene doesn't need it. As you can probably imagine the template errors can be obscene :)
The next thing would be to constexpr everything so that the scene could be built up in the compiler, I guess ideally in parts and then combined by the linker. I think it'll be really fun to try that with this Moana scene, but don't expect the compilers or linkers will survive let alone the tracer
EDIT to say, I really love your book. I feel hugely inspired every time I look at it, which unfortunately means I can't look too often as I don't have the time to play with these things as much as I'd like.
Personally I'm OK with the more aggressive optimisations, but they are still very controversial -- I think more so in the C than the C++ community (I'm in the C++ one).
Many ISPs are switching to carrier NAT though and then you can't host as you don't have a routable IP number.
So melting is an issue only for ice that melts on land and then flows into the oceans because that represents new water volume.