@AlexA. That's pretty much exactly what the code I suggested does: After the case statement, we check if it's negative immediately, and if it is, we force a break and it returns to wherever it needs to go--and at that point, in main, an exception is thrown.
One of the reasons I've always loved Pokemon is because for such a simple-seeming game, it has so many layers of complexity. Let's consider the move Hidden Power. In game, the type and power (at least before Generation VI) of Hidden Power is different for every Pokemon that uses it! That's pretty...
@AlexA. I wouldn't call detecting mismatched brackets in an interpreter a "fatal error." It's more of a "Oh, we thought we might get input like that. Good thing we know how to handle this. Alert our user, but don't make it look like we just crash"
@AlexA. It's better practice than returning NULL or something like that, but it's best to handle your exceptions, even if it means to ultimately log to STDERR and return 1; out of main
@AlexA. I misunderstood your program structure. In that case, you should log to stderr and return a non-zero value. I thought you were talking about throwing in a function that you call from main.
@quartata I think the update would be excluded, wouldn't it? If it postdates the sandbox, I mean
Anonymous
@AlexA. See word of god on exceptions. Basically, they're used to signal "hey something went wrong, and I can't handle it here, so something up the call chain needs to handle it" - throwing an exception from main makes little sense, since it is the top of the call chain.
@AlexA. Speaking of tabs, what does everyone in here use for whitespace?
Anonymous
On the matter of non-zero return values from programs: 0 should only be returned if the program successfully completed the operation(s) it was designed to do. If something goes wrong, at any point, it should return a non-zero value.
@Doorknob Ha, apparently I haven't been doing it wrong my whole life. I definitely have return 1 all over my old code as this-didn't-work notification. Why did I recently change my mind to the wrong one?
In computer networking, localhost is a hostname that means this computer or this host. It may be used to access the network services that are running on the host via its loopback network interface. Using the loopback interface bypasses and does not require any local network interface hardware. The local loopback mechanism may be useful for testing software during development, independently of any networking configurations. For example, if a computer has been configured to provide a website, directing a locally running web browser to http://localhost may display its home page.
On most computer systems...
natter is a social network where you can only use 3 words in each post and i spent all of last night posting messages as long as i wanted because it didn't detect non-breaking spaces correctly
JavaScript ES6, 46 bytes
Recursive, input as number to s, as in, s(1100110).
v=parseInt;s=x=>x==1?1:v(y=x+"",2)?s(v(y,2)):x
If string input is acceptable, then this works (41 bytes):
v=parseInt;s=x=>x==1?1:v(x,2)?s(v(x,2)):x
@quartata You could ping hichris or Undo. I know they set something up for AU. I also know it's very easy to configure which chatrooms Smokey posts in.