How will global perlish variables disappear?


(Laurent Julliard) #1

Hi gurus and nubys,

matz said more than once that the perlish global variables like
$/ or $: are going away in future releases.

I wonder if is there already a decision, what they will become?
I mean, it’s easy to think that $DEFAULT_INPUT may become a class
variable of IO but what about $1…$n or $: ?

More, would it be possible to have some kind of backward compat via an
external module ?


(Robert) #2

“gabriele renzi” surrender_it@remove.yahoo.it schrieb im Newsbeitrag
news:pefb30ds0n6tgcvtq6nce802f5s79g5bpc@4ax.com

Hi gurus and nubys,

No guru, just speculating…

matz said more than once that the perlish global variables like
$/ or $: are going away in future releases.

I wonder if is there already a decision, what they will become?
I mean, it’s easy to think that $DEFAULT_INPUT may become a class
variable of IO but what about $1…$n or $: ?

For $1…$n there is MatchData which is IHMO a better abstraction. Btw,
I’d prefer to have a MatchData instance in situations like

“foooo”.scan(/.(.)/) {|m| … }

(“m” is an Array here)

$: is IMHO a class constant of Kernel.

More, would it be possible to have some kind of backward compat via an
external module ?

Not if global variables are removed altogether. :slight_smile:

robert