Structured. Warnings. Now.

by Daniel Berger

The Problem

I find Ruby's current warning system, if you can call it that, lacking. Warnings are controlled by the -W flag on the command line, and are generated via the Kernel#warn method within code. There are a host of problems with this approach to warnings.


Dave Rolsky
2008-02-20 20:03:24
In Perl, warnings can be disabled lexically like this:

use warnings;


no warnings 'uninitialized';

print $may_be_undef + 0;

At the end of the block, all warnings are once again enabled. As far as testing them, of course you can, because you can "catch" warnings with $SIG{__WARN__}, and since this is Perl, there's a module on CPAN to help you, Test::Warn.

Gregor Schmidt
2008-02-21 04:00:06
I really like your proposal, so I started implementing it.

I just release a gem called "structured_warnings", that provides this functionality. I hope I did not step on your toe with this.

2008-02-21 19:01:23
I agree. This looks like a great idea. I never quite understood why warnings were fundamentally different from exceptions --which, btw, makes me wonder if this could actually be implemented piggy-back on top of the exception system somehow?
cheap wow accounts
2008-06-09 16:55:06
CTIN台湾cheap wow accounts联盟提供台湾cheap wow accounts与国外cheap wow accounts景点图片行程资讯报导,另提供旅行社cheap wow accounts行程与观光行程cheap wow accounts家园cheap wow accounts公司cheap wow accounts人策划创意. ... 中国cheap wow accounts业融入主流产业的先兆.武汉cheap wow accounts公司,武汉cheap wow accounts,cheap wow accounts武汉,湖北cheap wow accounts公司,武汉九重歌cheap wow accounts公司在湖北省及武汉cheap wow accounts公司中青在线cheap wow accounts频道是与中国青年报cheap wow accounts周刊、强强联手合作的cheap wow accounts频道。cheap wow accounts周刊,cheap wow accounts快报等信息栏目6787673@WOWGOLDS.COM