From: a7145@... Date: 2014-01-17T01:19:44+00:00 Subject: [ruby-core:59816] [ruby-trunk - Feature #9423] Improve warning semantics Issue #9423 has been updated by Atlas Prime. I realized if `-W0` is to remain the same meaning as it does now than one modification to the above idea is required: The warning levels must start with `1` instead of `0`. Zero would be equivalent to `nil`. So given that, and `example.rb` as: puts $WARN puts $VERBOSE It would be: $ruby -W0 example.rb nil nil $ruby -W1 example.rb 1 false $ruby -W2 example.rb 2 true $ruby -W3 example.rb 3 true $ruby -w example.rb 2 true Transitions would be (basically) # if no warnings if $VERBOSE.nil? -> if !$WARN # if medium warnings if $VERBOSE == false -> if $WARN # if strong warnings if $VERBOSE -> if $WARN && $WARN > 1 It would be nice if just `if $WARN > 1` would work for the last. But since $WARN can be `nil`, that's not possible. (Can `nil` be comparable to integers as if it were zero?) So while it would be nice for `$WARN == 0` to mean no warnings, instead of `nil`, it would mean that a simple `if $WARN` would not be possible --which I think is the preferable choice. ---------------------------------------- Feature #9423: Improve warning semantics https://bugs.ruby-lang.org/issues/9423#change-44389 * Author: Atlas Prime * Status: Feedback * Priority: Normal * Assignee: * Category: core * Target version: current: 2.2.0 ---------------------------------------- Two suggestions for future version of Ruby that wold make warning levels more intuitive easier to work with. First, rename $VERBOSE to $WARN for these reasons: * `ruby` flags that set $VERBOSE are `-w` and `-W` (warnings levels). * $VERBOSE controls output produced by `warn` method. * $VERBOSE and FileUtils:Verbose are unrelated. * $WARN is shorter ;-) Second, it is confusing that `nil` and `false` mean different levels. Instead of the current `nil` as level 0, `false` as level 1, and `true` as level 2, it would be nice if `nil` and `false` both mean "off", and then go from 0 on up to mean "on" of increasing degree. Just to clarify my meaning (not a use case example): # nil, false mean no warning if $WARN case $WARN when 0 # lesser level of warning when 1 # greater level of warning when 2 # can go higher if needed for rare use case end end These are incompatible changes, but can be phased-in with support both $WARN and $VERBOSE for intermediate period. -- http://bugs.ruby-lang.org/