On-topic
So, some people seem to find exceptions a bit wierd when they first come to Java or Python from C or some other language. I think the first time I saw them was in C++, and I found them a bit wierd.
I suspect a good way to explain them is by showing how you can get step-by-step from good C error-handling patterns to exceptions.
So for example the kernel is full of code on this pattern
{
int error;
....
error = -ENOMEM;
s = alloc_super();
if (!s) {
blkdev_put(bdev, BDEV_FS);
goto out;
}
...
out:
path_release(&nd);
return ERR_PTR(error);
}
In other words, if something goes wrong, you want to skip the rest of the function, do some cleanup, and propagate the error upwards. That maps pretty straightforwardly to
try:
s = alloc_super()
if not s:
raise 'not enough memory'
return s
finally:
path_release(nd)
Similarly for except statements and so on. Hopefully a worthwhile howto or something will come out of it, and people will feel more happy using exceptions for good, not for evil.
Off-topic
I know I probably shouldn't write about this, but I'm only human...
I guess bytesplit is probably a fine person in many ways, and he now seems to be using the site more or less as designed, but his arrival and initial posts were pretty annoying to me.
It feels like a lot of people, including me, are giving up their time to try to write good software for the world, and it's annoying when somebody just seems to want to piss all over it. I really would just quit, except that I care much more about the opinions of the genuinely friendly and bright people involved in it.
At some level I know it's a big bad world, and that will always happen, but it's still not nice to see this happen. I don't think that post, or this one is called for; it wouldn't be polite in person and it ought not to be acceptable here. It still seems to me to be counterproductive for bytesplit to want to be part of free software but also to insult people he could learn from.
The guy is obviously, admittedly, new to Linux: doesn't know C, doesn't(?) have a Unix box yet, etc. Nothing wrong with that; certainly not a sign of moral failure or lack of intelligence; everybody was there once. However, I do think it's reasonable for a beginner to show a little amount of respect.
I can admit that my previous post was a bit flamacious. It would be reasonable, and kind of nice, for him to apologize, but if he can just be civil in future I guess that would be good enough.
I've tried to make this entry as moderate as I can. I half expect that he will just flame me in a similarly illiterate and ridiculous vein, but we shall see. Honestly and objectively, if he thinks I'm being unreasonable, then I just can't imagine him ever working constructively on an open source project.