anything disappearing from Ruby for 2.0?

D

David A. Black

Hi --

An open question for Matz:

Is anything disappearing from Ruby in 2.0? Not that I have a very big
list of things I want removed :) but I'm wondering, for example,
about the Perl-like special variables. And just wondering generally
if there's anything in that category.


David
 
J

Joel VanderWerf

David said:
Hi --

An open question for Matz:

Is anything disappearing from Ruby in 2.0? Not that I have a very big
list of things I want removed :) but I'm wondering, for example,
about the Perl-like special variables. And just wondering generally
if there's anything in that category.

If the perlish globals are going away, then that suggests another
possibility that would make the remaining globals more regular. I often
have to look up which globals are per-thread (and this was especially
true when I was starting out with ruby). What if the name of the global
determined in a very simple way whether is was per-thread or not?

For example, the rule could be: all globals matching /\$_\w*/ are
per-thread. All others are per-process. That's consistent with the
current use of $_, which is per-thread.

What breaks? Well, if you take out all the perlish variables from the
list in the Pickaxe (pp.216-218), the only variable whose behavior would
change is $SAFE. So that would have to be replaced with $_SAFE, or left
as a special case (perhaps with a warning, and expiring after a while).
I'd rather remember one special case than two pages of them. The
standard library is unaffected, aside from any use of $SAFE, since there
are no variables in it that match /\$_\w+/. Same goes for all the RAA
projects that I've downloaded.

This change would also make it easy to work with user-defined thread
local variables. Instead of

Thread.new {
Thread.current[:foo] = 3
}

you could simply do

Thread.new {
$_foo = 3
}

I guess that's probably more efficient, too, since it saves a method call.
 
Y

Yukihiro Matsumoto

Hi,

In message "anything disappearing from Ruby for 2.0?"

|Is anything disappearing from Ruby in 2.0? Not that I have a very big
|list of things I want removed :) but I'm wondering, for example,
|about the Perl-like special variables. And just wondering generally
|if there's anything in that category.

Candidates are:

* Perl style variables
* ../... in condition
* regex literal in condition
* Prec module
* maybe a few other things I can't think of now

matz.
 
P

Phil Tomson

Hi,

In message "anything disappearing from Ruby for 2.0?"

|Is anything disappearing from Ruby in 2.0? Not that I have a very big
|list of things I want removed :) but I'm wondering, for example,
|about the Perl-like special variables. And just wondering generally
|if there's anything in that category.

Candidates are:

* ../... in condition
* regex literal in condition

Why these two? So you mean that we could no longer say:

case year
when 1981 .. 1989 then "Reagan"
when 1989 .. 1992 then "Bush"
when 1993 .. 2000 then "Clinton"
when 2001 .. 2004 then "BushII"
end

or:

case line
when /failed/
failed +=1
when /warning/
warning +=1
when /pass/
pass +=1
end

I'd certainly miss not being able to do these sorts of things.
* Prec module
Prec?

* maybe a few other things I can't think of now

Phil
 
J

Josef 'Jupp' SCHUGT

Hi!

* Yukihiro Matsumoto; 2003-11-29, 21:58 UTC:
In message "anything disappearing from Ruby for 2.0?"

|Is anything disappearing from Ruby in 2.0? Not that I have a very big
|list of things I want removed :) but I'm wondering, for example,
|about the Perl-like special variables. And just wondering generally
|if there's anything in that category.

Candidates are:

* Perl style variables

[SNIP]

Just removal of $#{some_character} or also removal of
${Insert_some_alias_from_English_dot_rb} ?

Josef 'Jupp' Schugt
 
M

Michael Campbell

Yukihiro said:
Candidates are:

* Perl style variables
* ../... in condition

Ack, no more:

if (/foo/ .. /bar/) ?

I find this construct terribly useful; I'd hate to see it go.
 
F

Florian Gross

Yukihiro said:
Hi,
Moin!

|Is anything disappearing from Ruby in 2.0?
Candidates are:
* Perl style variables
* ../... in condition
* regex literal in condition
* Prec module
* maybe a few other things I can't think of now

What about @@variables? As I see it they're confusing a large amount of
new Ruby users and I don't see how they shouldn't be replaced with
simpler attr_accessors in classes instead. (e.g. @@foo would be
self.class.foo)

I also find the module-syntax to be quite counter-intuitive, because you
have to do 'module Foo; class << self' to get real namespaces. I think
there maybe should be a separate namespace-construct. I'd also like to
rename 'module' to 'mixin', but that might be too radical.

I'm sure there's more that I'm not able to think off right now.

Regards,
Florian Gross
 
T

T. Onoma

I also find the module-syntax to be quite counter-intuitive, because you
have to do 'module Foo; class << self' to get real namespaces. I think
there maybe should be a separate namespace-construct. I'd also like to
rename 'module' to 'mixin', but that might be too radical.

Modules are strange beasts in that they serve at least three puposes. They can
be used as mixins using include, in which case they act as "pseudo"
superclasses; they can be used to extend an object, in which case the become
a singleton class, and thirdly they sever as simple namespaces.

Quite a heavy load for the a single contruct, ey? Oh, four! They are also the
foundation of Class!

-t0
 
F

Ferenc Engard

Candidates are:
* Perl style variables

If you still intend to use ruby for one-liners, then they should remain
IMHO. Anyway, they do not harm anybody. I vote to not removing them.

Or, maybe to not defining them by default, but enabling them with a
cmdline switch?

Ferenc
 
D

David Garamond

Ferenc said:
If you still intend to use ruby for one-liners, then they should remain
IMHO. Anyway, they do not harm anybody. I vote to not removing them.

Or, maybe to not defining them by default, but enabling them with a
cmdline switch?

I second that. Ruby has been a great Perl replacement for me partly
because of this. Though the more I use Ruby, the less I use $_ and
friends. The only variables I still use quite often is $1, $2, ... They
are globals, not thread-safe, etc, but great for oneliners.
 
K

Kent Dahl

Florian said:
What about @@variables? As I see it they're confusing a large amount of
new Ruby users and I don't see how they shouldn't be replaced with
simpler attr_accessors in classes instead. (e.g. @@foo would be
self.class.foo)

Class instance variables aren't inherited and the attr_accessors would
have to be pretty niftily implemented to serve the same purpose as
@@vars do now.

I've seen lots of threads on how to do it with attr, and maybe I've
misunderstood something but I can't help but think that:
a) they don't cover all the uses of @@vars
b) those rather mindbending implementations that did come close,
reeked of overhead and really just makes a slower, syntactic sugar
version of @@vars.

IMHO.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|I second that. Ruby has been a great Perl replacement for me partly
|because of this. Though the more I use Ruby, the less I use $_ and
|friends. The only variables I still use quite often is $1, $2, ... They
|are globals, not thread-safe, etc, but great for oneliners.

Match related variables ($&, $1, $2,...) are locals and thread-safe.


matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|> * Perl style variables
|
|Just removal of $#{some_character} or also removal of
|${Insert_some_alias_from_English_dot_rb} ?

Both. But I have consider about each variable before removing. Some
of them are useful.

matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|Ack, no more:
|
|if (/foo/ .. /bar/) ?
|
|I find this construct terribly useful; I'd hate to see it go.

Perhaps some other way to accomplish, for example,

IO#from_to(re1, re2) {|line| ... }

just an idea.

matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|What about @@variables?

They will remain, although I have a plan to change the class variable
behavior.

|As I see it they're confusing a large amount of
|new Ruby users and I don't see how they shouldn't be replaced with
|simpler attr_accessors in classes instead. (e.g. @@foo would be
|self.class.foo)

"self.class.foo" would not do the things I wanted to accomplish by
class variables. They are global variables scope limited to
surrounding class/module.

matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|Modules are strange beasts in that they serve at least three puposes. They can
|be used as mixins using include, in which case they act as "pseudo"
|superclasses; they can be used to extend an object, in which case the become
|a singleton class, and thirdly they sever as simple namespaces.
|
|Quite a heavy load for the a single contruct, ey? Oh, four! They are also the
|foundation of Class!

It will not be changed. Ruby will remain being Ruby even after Ruby2.
Perhaps some next generation language would have constructs for each
role.

matz.
 
C

Chris Uppal

Ferenc said:
If you still intend to use ruby for one-liners, then they should remain
IMHO. Anyway, they do not harm anybody. I vote to not removing them.

[I'm an outsider delurking on this newsgroup for the first time]

I want to add the observation that the Perlisms in Ruby were a major (perhaps
*the* major) factor that put me off the language when I looked at it a year or
so ago.

-- chris
 
T

T. Onoma

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|Modules are strange beasts in that they serve at least three puposes. They
| can be used as mixins using include, in which case they act as "pseudo"
| superclasses; they can be used to extend an object, in which case the
| become a singleton class, and thirdly they sever as simple namespaces.
|
|Quite a heavy load for the a single contruct, ey? Oh, four! They are also
| the foundation of Class!

It will not be changed. Ruby will remain being Ruby even after Ruby2.
Perhaps some next generation language would have constructs for each
role.

You pegged me wrong Matz! It is not that I want them to, per se. I was just
pointing it out.

-t0
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|> It will not be changed. Ruby will remain being Ruby even after Ruby2.
|> Perhaps some next generation language would have constructs for each
|> role.
|
|You pegged me wrong Matz! It is not that I want them to, per se. I was just
|pointing it out.

I meant "if someone (not only you, Tom) want to change, wait for (or
create your own) next generation language."

matz.
 
T

T. Onoma

Hi,

In message "Re: anything disappearing from Ruby for 2.0?"

|> It will not be changed. Ruby will remain being Ruby even after Ruby2.
|> Perhaps some next generation language would have constructs for each
|> role.
|
|You pegged me wrong Matz! It is not that I want them to, per se. I was
| just pointing it out.

I meant "if someone (not only you, Tom) want to change, wait for (or
create your own) next generation language."

Okay, just wanted to be clear on where I stood on that.

Thanks,
-t0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top