3 ms·
There exists a much simpler way, it is for example how C++ compilers deal with recursion in template instantiation: for level = 1 to arbitrary_depth: do_
by qb45 9y ago
There exists a much simpler way, it is for example how C++ compilers deal with recursion in template instantiation:
for level = 1 to arbitrary_depth:
do_some_work_which_may_produce_more_work()
You just have to select arbitrary_depth large enough that nobody notices and there you have it - arbitrarily deep recursion without infinite loop ;)
Totally wouldn't be surprised if MS did it this way too. Otherwise you are right - they would need to remember at least hashes of all "outer" archives unpacked so far.
- nathan_f77 9y agoHaha, that's how I like to write all my code now. Sometimes I'll write a function that generates a random id, and checks the database to make sure that it doesn't already exist. I always like to add a counter and throw an error (or just return some default value) if it gets up to 100 or so. It might not ever happen in this universe, but I like to imagine there's a parallel universe out there where I saved some server from going into an infinite loop. I actually did this recently for a random phone number generator, using the phony Ruby library to validate numbers. It was just for some test fixtures, but it's nice to know that it will always fallback to a default test number in case something goes wrong and it runs out of attempts. Or I'm in some universe where my random number generator suddenly starts producing an endless stream of zero bits. This is just a little 'tick'. I also find myself using 12px and 14px a lot more frequently than 13px.
- Terr_ 9y agoThat would avoid getting stuck, but in an adversarial situation, that hands the attacker an easy attack: Just use N+1 layers of packing. ... So it really needs to be semi-random :p