ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:59809] [ruby-trunk - Feature #9423] [Open] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
@ 2014-01-16 16:14 ` a7145
  2014-01-16 22:17 ` [ruby-core:59812] [ruby-trunk - Feature #9423] [Feedback] " nobu
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: a7145 @ 2014-01-16 16:14 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been reported by Atlas Prime.

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423

* Author: Atlas Prime
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:59812] [ruby-trunk - Feature #9423] [Feedback] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
  2014-01-16 16:14 ` [ruby-core:59809] [ruby-trunk - Feature #9423] [Open] Improve warning semantics a7145
@ 2014-01-16 22:17 ` nobu
  2014-01-17  1:19 ` [ruby-core:59816] [ruby-trunk - Feature #9423] " a7145
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2014-01-16 22:17 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Nobuyoshi Nakada.

Status changed from Open to Feedback

Could you illustrate "support both $WARN and $VERBOSE for intermediate period" more?

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-44383

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:59816] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
  2014-01-16 16:14 ` [ruby-core:59809] [ruby-trunk - Feature #9423] [Open] Improve warning semantics a7145
  2014-01-16 22:17 ` [ruby-core:59812] [ruby-trunk - Feature #9423] [Feedback] " nobu
@ 2014-01-17  1:19 ` a7145
  2014-01-17  2:19 ` [ruby-core:59818] " nobu
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: a7145 @ 2014-01-17  1:19 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:59818] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-01-17  1:19 ` [ruby-core:59816] [ruby-trunk - Feature #9423] " a7145
@ 2014-01-17  2:19 ` nobu
  2014-01-18 15:21 ` [ruby-core:59852] " a7145
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2014-01-17  2:19 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Nobuyoshi Nakada.


Then, what about a method, instead of another global variable, like as:


- if no warnings

  ```
  unless warning?(0)
  # ...
  end
  ```

- if medium warnings

  ```
  if warning?(0)
  # ...
  end
  ```
  or

  ```
  warning?(0) do
  # ...
  end
  ```

- if strong warnings

  ```
  if warning?
  # ...
  end
  ```
  or

  ```
  warning? do
  # ...
  end
  ```


----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-44391

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:59852] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-01-17  2:19 ` [ruby-core:59818] " nobu
@ 2014-01-18 15:21 ` a7145
  2014-01-23 22:27 ` [ruby-core:60035] " djberg96
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: a7145 @ 2014-01-18 15:21 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Atlas Prime.


That's a great idea! Abstracting the interface away as a method leaves the underpinnings free for adjustment. With that, it seems most intuitive that `-W[level]` would simply translate directly into $WARN=level. And `-W0` flag would still mean "no warnings".

I worked on making an exact definition `#warning?`. It soon become clear to me that it was more complicated than it seemed it should be b/c what it was really calling for two methods, not just one. With two methods it becomes very simple. What do you think of:

    # medium warnings
    if notice?
      $WARN >= 1
    end

    # strong warnings
    if warning?(level=2)
      $WARN >= level
    end

That way we can use `if` and `unless` on either `notice?` or `warning?` and not have to worry about the level at all (except for supporting rare high levels >= 3).


----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-44420

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:60035] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-01-18 15:21 ` [ruby-core:59852] " a7145
@ 2014-01-23 22:27 ` djberg96
  2014-02-05 13:54 ` [ruby-core:60507] " a7145
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: djberg96 @ 2014-01-23 22:27 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Daniel Berger.


What we need are structured warnings, not a warning level system.

https://github.com/schmidt/structured_warnings

http://www.oreillynet.com/ruby/blog/2008/02/structured_warnings_now.html

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-44552

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:60507] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-01-23 22:27 ` [ruby-core:60035] " djberg96
@ 2014-02-05 13:54 ` a7145
  2014-02-07  2:40 ` [ruby-core:60554] " djberg96
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 10+ messages in thread
From: a7145 @ 2014-02-05 13:54 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Atlas Prime.


Daniel, that does seem like an even better idea. But it's also a much bigger change. I wonder what effect would that have on performance? Also, I wonder if there could still some type of "severity" level. For instance I could imagine wanting certain warnings to behave like errors so I could root them out when testing.


----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-44971

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:60554] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-02-05 13:54 ` [ruby-core:60507] " a7145
@ 2014-02-07  2:40 ` djberg96
  2014-02-26 13:35 ` [ruby-core:61107] " franck
  2015-05-04  2:12 ` [ruby-core:69066] [Ruby trunk " djberg96
  9 siblings, 0 replies; 10+ messages in thread
From: djberg96 @ 2014-02-07  2:40 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Daniel Berger.


I wouldn't think it would have a major impact on performance since (hopefully) not that many warnings are issued in practice.

I think compilers have a "treat warnings as errors" flag, so I suppose Ruby could do something similar. I think that's much less important for Ruby though, since often the warnings are something you can't usually do anything about, whereas in C they often indicate a possible bug.

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-45008

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:61107] [ruby-trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-02-07  2:40 ` [ruby-core:60554] " djberg96
@ 2014-02-26 13:35 ` franck
  2015-05-04  2:12 ` [ruby-core:69066] [Ruby trunk " djberg96
  9 siblings, 0 replies; 10+ messages in thread
From: franck @ 2014-02-26 13:35 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Franck Verrot.


I hope this is a related question: is one supposed to link the $VERBOSE/$WARN levels to the "Logger" object's level? If so, how?

I am currently trying to figure out if they represent the same notion, or if the $VERBOSE levels are more related to the interpreter's, and the Logger ones let under each developer's responsibility.

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-45492

* 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/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:69066] [Ruby trunk - Feature #9423] Improve warning semantics
       [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-02-26 13:35 ` [ruby-core:61107] " franck
@ 2015-05-04  2:12 ` djberg96
  9 siblings, 0 replies; 10+ messages in thread
From: djberg96 @ 2015-05-04  2:12 UTC (permalink / raw
  To: ruby-core

Issue #9423 has been updated by Daniel Berger.


Any thoughts on structured warnings core team?

----------------------------------------
Feature #9423: Improve warning semantics
https://bugs.ruby-lang.org/issues/9423#change-52316

* Author: Atlas Prime
* Status: Feedback
* Priority: Normal
* Assignee: 
----------------------------------------
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.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-05-04  1:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9423.20140116161435@ruby-lang.org>
2014-01-16 16:14 ` [ruby-core:59809] [ruby-trunk - Feature #9423] [Open] Improve warning semantics a7145
2014-01-16 22:17 ` [ruby-core:59812] [ruby-trunk - Feature #9423] [Feedback] " nobu
2014-01-17  1:19 ` [ruby-core:59816] [ruby-trunk - Feature #9423] " a7145
2014-01-17  2:19 ` [ruby-core:59818] " nobu
2014-01-18 15:21 ` [ruby-core:59852] " a7145
2014-01-23 22:27 ` [ruby-core:60035] " djberg96
2014-02-05 13:54 ` [ruby-core:60507] " a7145
2014-02-07  2:40 ` [ruby-core:60554] " djberg96
2014-02-26 13:35 ` [ruby-core:61107] " franck
2015-05-04  2:12 ` [ruby-core:69066] [Ruby trunk " djberg96

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).