ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50393] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
@ 2017-12-26  8:08 ` akr
  2017-12-26  8:13 ` [ruby-dev:50394] " matz
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: akr @ 2017-12-26  8:08 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been reported by akr (Akira Tanaka).

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50394] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
  2017-12-26  8:08 ` [ruby-dev:50393] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\ akr
@ 2017-12-26  8:13 ` matz
  2017-12-26  8:55   ` [ruby-dev:50396] " Eric Wong
  2017-12-26 11:08 ` [ruby-dev:50398] " shevegen
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 16+ messages in thread
From: matz @ 2017-12-26  8:13 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by matz (Yukihiro Matsumoto).


Agreed.

Besides that, we should warn for `$=` and `$.`, I think.

Matz.


----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-68967

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50396] Re: [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
  2017-12-26  8:13 ` [ruby-dev:50394] " matz
@ 2017-12-26  8:55   ` Eric Wong
  2017-12-26  9:23     ` [ruby-dev:50397] Re: [ruby-core:84472] " Tanaka Akira
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Wong @ 2017-12-26  8:55 UTC (permalink / raw)
  To: ruby-core; +Cc: ruby-dev

Shouldn't English posts be on ruby-core instead of ruby-dev?

matz@ruby-lang.org wrote:
> Agreed.
> 
> Besides that, we should warn for `$=` and `$.`, I think.

I find $., $\, and $/ useful for oneliners, at least.  $.
especially

I'm fine with awk-compatible English.rb names ($NR, $ORS, $RS)
by default, but I do not like the long names in English.rb.

I like having some awk and Perl-isms in Ruby :>

(quoting the rest for -core)

> Matz.
> 
> 
> ----------------------------------------
> Bug #14240: warn four special variables: $; $, $/ $\
> https://bugs.ruby-lang.org/issues/14240#change-68967
> 
> * Author: akr (Akira Tanaka)
> * Status: Open
> * Priority: Normal
> * Assignee: 
> * Target version: 
> * ruby -v: 
> * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
> ----------------------------------------
> I think the four special variables for separators should be deprecated.
> 
> ```
> $/    input record separator (default argument for "gets")
> $\    output record separator ("print" prints it at last)
> $,    default separator for Array#join and print
> $;    default separator for String#split
> ```
> 
> I feel many program doesn't work if they are set to non-default value.
> 
> Since they are global, not thread local,
> we can not change these variables safely in a multi threaded program.
> 
> So, I think we should warn them (and delete them in future).

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

* [ruby-dev:50397] Re: [ruby-core:84472] Re: [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
  2017-12-26  8:55   ` [ruby-dev:50396] " Eric Wong
@ 2017-12-26  9:23     ` Tanaka Akira
  2017-12-26 19:52       ` [ruby-dev:50400] Re: [ruby-core:84476] " Eric Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Tanaka Akira @ 2017-12-26  9:23 UTC (permalink / raw)
  To: Ruby developers; +Cc: ruby developers list

2017-12-26 17:55 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
> Shouldn't English posts be on ruby-core instead of ruby-dev?

Oops.  Sorry.

>> Besides that, we should warn for `$=` and `$.`, I think.
>
> I find $., $\, and $/ useful for oneliners, at least.  $.
> especially

Hm.  One idea to support oneliners is that warn the
special variables when -e option is not given.
-- 
Tanaka Akira

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

* [ruby-dev:50398] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
  2017-12-26  8:08 ` [ruby-dev:50393] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\ akr
  2017-12-26  8:13 ` [ruby-dev:50394] " matz
@ 2017-12-26 11:08 ` shevegen
  2017-12-26 21:15 ` [ruby-dev:50401] " eregontp
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: shevegen @ 2017-12-26 11:08 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by shevegen (Robert A. Heiler).


By the way, the awk-inspired names such as $NR, $ORS, $RS,
also do not tell me anything. :-)

In fairness, I also have to admit that the english names also
do not always tell me that much more. Depends on the name.

http://ruby-doc.org/stdlib/libdoc/English/rdoc/English.html

    $\ = ' -- '
    "waterbuffalo" =~ /buff/
    print $', $$, "\n"

versus

    require "English"

    $OUTPUT_FIELD_SEPARATOR = ' -- '
    "waterbuffalo" =~ /buff/
    print $POSTMATCH, $PID, "\n"

The second variant is a tiny bit more readable to me, but
I also can not tell you what $OUTPUT_FIELD_SEPARATOR really
means, without having to look at the docu. :)
And $POSTMATCH hmm... I can try to make a guess, but I am
not sure. I'd have to look at the docu. :D

Only $PID I can infer at once... to mean the PID of a
process. I like that name. Please tell me that it does
not mean anything else than PID ... :D

My brain takes more time for the first code variant and
in general, I try to write only very simply code in ruby
(which is also why I am absolutely bad at golfing and
one-liners, but I understand if people want to be able
to be super-succinct ... I remember the xmas tree in
code golfing, that's more like art than code though).

What actually  makes me not use "English" there is the require
line - see also headius' suggestion elsewhere. I liked the recent
change in regards to pp for similar reason, less to type. :)
(Although I was using pp a LOT nonetheless, it is too useful to me
to not make use of it. It just is less typing for me now
past 2.5.x)

Anyway, I digress so I better stop now.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-68993

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50400] Re: [ruby-core:84476] Re: [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
  2017-12-26  9:23     ` [ruby-dev:50397] Re: [ruby-core:84472] " Tanaka Akira
@ 2017-12-26 19:52       ` Eric Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Wong @ 2017-12-26 19:52 UTC (permalink / raw)
  To: ruby-core; +Cc: ruby-dev

Tanaka Akira <akr@fsij•org> wrote:
> >> Besides that, we should warn for `$=` and `$.`, I think.

> 2017-12-26 17:55 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
> > I find $., $\, and $/ useful for oneliners, at least.  $.
> > especially
> 
> Hm.  One idea to support oneliners is that warn the
> special variables when -e option is not given.

Can we have the warnings forever?  (No removal, ever).
I would be happy with that :)

One important thing about oneliners is you won't find many
examples of them in code search engines to judge popularity.

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

* [ruby-dev:50401] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-12-26 11:08 ` [ruby-dev:50398] " shevegen
@ 2017-12-26 21:15 ` eregontp
  2018-01-24  8:22 ` [ruby-dev:50425] " akr
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: eregontp @ 2017-12-26 21:15 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by Eregon (Benoit Daloze).


I agree.
These global variables can only be useful in tiny scripts,
and even then I believe none of them are idiomatic Ruby code.

All of these are shortcuts saving at best a couple characters,
but also threaten any usage of gets/print/split/join methods in larger programs.
Giving an argument gets/print/split/join is much clearer and safer.

I was already thinking along the same lines 6 years ago about $, in https://bugs.ruby-lang.org/issues/5977,
after being caught by a bug of some library setting $, and breaking the rest in very surprising ways iirc.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-69003

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50425] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-12-26 21:15 ` [ruby-dev:50401] " eregontp
@ 2018-01-24  8:22 ` akr
  2018-01-25 10:10 ` [ruby-dev:50431] " nobu
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: akr @ 2018-01-24  8:22 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by akr (Akira Tanaka).


We discussed this issue at today's developper meeting.

We (including matz) agree produce warnings for 5 variables ($; $, $/ $\ $.) when it is written in
ruby code except -e argument.

The warning is produced at compile time.
So the warning is produced once for each occurrence (even if it occurs in a loop).

Note that $= already produces a warning since ruby 1.9.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-69747

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50431] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2018-01-24  8:22 ` [ruby-dev:50425] " akr
@ 2018-01-25 10:10 ` nobu
  2019-07-26 23:19 ` [ruby-dev:50820] [Ruby master " merch-redmine
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2018-01-25 10:10 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by nobu (Nobuyoshi Nakada).


I wonder that aliased variables also should be warned, `$-0`, `$-F`, and aliases in English.rb.

Currently, aliases of `$KCODE` are also warned.
In other words, the feature of `$KCODE` is warned (and has no effect now).

Should we warn these four variable names, or their features?



----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-69821

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).







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

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

* [ruby-dev:50820] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2018-01-25 10:10 ` [ruby-dev:50431] " nobu
@ 2019-07-26 23:19 ` merch-redmine
  2019-07-27  1:54 ` [ruby-dev:50821] " nobu
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: merch-redmine @ 2019-07-26 23:19 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by jeremyevans0 (Jeremy Evans).

File warn-5-gvars.patch added

Attached is a patch that adds a deprecation warning for the 5 global variables ($; $, $/ $\ $.), unless inside ruby `-e`.  However, there is use of these variables inside Ruby that should be fixed if we plan to make this change.  I've already seen the following issues:

```
/path/ruby/lib/erb.rb:907: warning: global variable $. is deprecated
../.././ext/ripper/tools/preproc.rb: warning: global variable $/ is deprecated
/path/ruby/lib/rubygems/specification.rb:14: warning: global variable $. is deprecated
```

It is likely there are more issues than just these three.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-80125

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)


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

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

* [ruby-dev:50821] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-07-26 23:19 ` [ruby-dev:50820] [Ruby master " merch-redmine
@ 2019-07-27  1:54 ` nobu
  2019-07-29 19:03 ` [ruby-dev:50823] " merch-redmine
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2019-07-27  1:54 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by nobu (Nobuyoshi Nakada).


It does not match to test `rb_warn` with `assert_warning`.
Should be `rb_warn`+`assert_warn` or `rb_warning`+`assert_warning`.

And non-default `$;` and `$,` are warned now.
Do you think these **names** should be warned too?

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-80127

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)


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

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

* [ruby-dev:50823] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-07-27  1:54 ` [ruby-dev:50821] " nobu
@ 2019-07-29 19:03 ` merch-redmine
  2019-07-30  1:52 ` [ruby-dev:50824] " nobu
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: merch-redmine @ 2019-07-29 19:03 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by jeremyevans0 (Jeremy Evans).

File warn-5-gvars-v2.patch added

nobu (Nobuyoshi Nakada) wrote:
> It does not match to test `rb_warn` with `assert_warning`.
> Should be `rb_warn`+`assert_warn` or `rb_warning`+`assert_warning`.

Thanks. I switched to `assert_warn`, as I think deprecation warnings should be a regular warning, not a verbose warning.  Verbose warnings are best used for warnings like unused variables.  I only think verbose deprecation warnings should be used if there is a plan to follow it up with a non-verbose deprecation warning before removing it.

> And non-default `$;` and `$,` are warned now.
> Do you think these **names** should be warned too?

I don't feel strongly about it.  The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values.  akr's previous comment indicated that the warnings of the five variables should be at compile time.

One problem with the implementation in my previous patch is that it warns at the wrong location. Switching from `rb_warn` to `rb_compile_warn` fixes that issue.

Attached is an updated patch, as well as a few fixes where the global variables are currently used.  Another file where they are also currently used is in:

```
/path/ruby/lib/rubygems/stub_specification.rb:114: warning: global variable $. is deprecated
/path/ruby/lib/rubygems/stub_specification.rb:134: warning: global variable $. is deprecated
```

But a fix there should be filed upstream.

There are probably additional cases where these global variables are used internally.  At the very least all tests that use them probably need modification to hide the warnings.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-80202

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)


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

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

* [ruby-dev:50824] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2019-07-29 19:03 ` [ruby-dev:50823] " merch-redmine
@ 2019-07-30  1:52 ` nobu
  2019-08-26  0:58 ` [ruby-dev:50837] " merch-redmine
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2019-07-30  1:52 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by nobu (Nobuyoshi Nakada).


jeremyevans0 (Jeremy Evans) wrote:
> > And non-default `$;` and `$,` are warned now.
> > Do you think these **names** should be warned too?
> 
> I don't feel strongly about it.  The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values.  akr's previous comment indicated that the warnings of the five variables should be at compile time.

There are tons of that warnings, and it is not easy to suppress parser warning within the given file only.

> One problem with the implementation in my previous patch is that it warns at the wrong location. Switching from `rb_warn` to `rb_compile_warn` fixes that issue.

It should be `rb_warn1` and `WARN_I(c)` for ripper.
And a typo `f.line_no` in template/encdb.h.tmpl.


----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-80221

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)


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

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

* [ruby-dev:50837] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2019-07-30  1:52 ` [ruby-dev:50824] " nobu
@ 2019-08-26  0:58 ` merch-redmine
  2019-08-26  4:33 ` [ruby-dev:50838] " nobu
  2019-12-26  2:39 ` [ruby-dev:50902] [Ruby master Feature#14240] " mame
  12 siblings, 0 replies; 16+ messages in thread
From: merch-redmine @ 2019-08-26  0:58 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by jeremyevans0 (Jeremy Evans).

File warn-5-gvars-v3.patch added

nobu (Nobuyoshi Nakada) wrote:
> jeremyevans0 (Jeremy Evans) wrote:
> > > And non-default `$;` and `$,` are warned now.
> > > Do you think these **names** should be warned too?
> > 
> > I don't feel strongly about it.  The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values.  akr's previous comment indicated that the warnings of the five variables should be at compile time.
> 
> There are tons of that warnings, and it is not easy to suppress parser warning within the given file only.

Agreed.  I'm fine dropping these compile warnings if the run-time warnings are considered sufficient.

> > One problem with the implementation in my previous patch is that it warns at the wrong location. Switching from `rb_warn` to `rb_compile_warn` fixes that issue.
> 
> It should be `rb_warn1` and `WARN_I(c)` for ripper.
> And a typo `f.line_no` in template/encdb.h.tmpl.

Thanks for the review.  Attached is an updated patch that fixes these issues.

----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-81004

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)
warn-5-gvars-v3.patch (5.4 KB)


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

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

* [ruby-dev:50838] [Ruby master Bug#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2019-08-26  0:58 ` [ruby-dev:50837] " merch-redmine
@ 2019-08-26  4:33 ` nobu
  2019-12-26  2:39 ` [ruby-dev:50902] [Ruby master Feature#14240] " mame
  12 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2019-08-26  4:33 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by nobu (Nobuyoshi Nakada).


jeremyevans0 (Jeremy Evans) wrote:
> nobu (Nobuyoshi Nakada) wrote:
> > jeremyevans0 (Jeremy Evans) wrote:
> > > > And non-default `$;` and `$,` are warned now.
> > > > Do you think these **names** should be warned too?
> > > 
> > > I don't feel strongly about it.  The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values.  akr's previous comment indicated that the warnings of the five variables should be at compile time.
> > 
> > There are tons of that warnings, and it is not easy to suppress parser warning within the given file only.
> 
> Agreed.  I'm fine dropping these compile warnings if the run-time warnings are considered sufficient.

Another point is that compile warnings are for the names.
Use of aliases of them like English.rb will be still silent.

So, [this question](https://bugs.ruby-lang.org/issues/14240#note-13).
> Should we warn these four variable names, or their features?


----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-81009

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)
warn-5-gvars-v3.patch (5.4 KB)


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

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

* [ruby-dev:50902] [Ruby master Feature#14240] warn four special variables: $; $, $/ $\
       [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-08-26  4:33 ` [ruby-dev:50838] " nobu
@ 2019-12-26  2:39 ` mame
  12 siblings, 0 replies; 16+ messages in thread
From: mame @ 2019-12-26  2:39 UTC (permalink / raw)
  To: ruby-dev

Issue #14240 has been updated by mame (Yusuke Endoh).

Target version set to 2.8
Assignee set to jeremyevans0 (Jeremy Evans)

At the previous dev meeting, matz said that it should display a warning dynamically, i.e., not at the parsing time but when the variables are assigned.  Variable aliases should be also warned.  @jeremyevans0, could you please progress?

----------------------------------------
Feature #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-83410

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: jeremyevans0 (Jeremy Evans)
* Target version: 2.8
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)
warn-5-gvars-v3.patch (5.4 KB)


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

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

end of thread, other threads:[~2019-12-26  2:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-14240.20171226080808@ruby-lang.org>
2017-12-26  8:08 ` [ruby-dev:50393] [Ruby trunk Bug#14240] warn four special variables: $; $, $/ $\ akr
2017-12-26  8:13 ` [ruby-dev:50394] " matz
2017-12-26  8:55   ` [ruby-dev:50396] " Eric Wong
2017-12-26  9:23     ` [ruby-dev:50397] Re: [ruby-core:84472] " Tanaka Akira
2017-12-26 19:52       ` [ruby-dev:50400] Re: [ruby-core:84476] " Eric Wong
2017-12-26 11:08 ` [ruby-dev:50398] " shevegen
2017-12-26 21:15 ` [ruby-dev:50401] " eregontp
2018-01-24  8:22 ` [ruby-dev:50425] " akr
2018-01-25 10:10 ` [ruby-dev:50431] " nobu
2019-07-26 23:19 ` [ruby-dev:50820] [Ruby master " merch-redmine
2019-07-27  1:54 ` [ruby-dev:50821] " nobu
2019-07-29 19:03 ` [ruby-dev:50823] " merch-redmine
2019-07-30  1:52 ` [ruby-dev:50824] " nobu
2019-08-26  0:58 ` [ruby-dev:50837] " merch-redmine
2019-08-26  4:33 ` [ruby-dev:50838] " nobu
2019-12-26  2:39 ` [ruby-dev:50902] [Ruby master Feature#14240] " mame

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).