[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

anything disappearing from Ruby for 2.0?

dblack

11/28/2003 11:25:00 PM

58 Answers

Joel VanderWerf

11/29/2003 1:24:00 AM

0

David A. Black wrote:
> 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.



matz

11/29/2003 5:02:00 PM

0

Hi,

In message "anything disappearing from Ruby for 2.0?"
on 03/11/29, "David A. Black" <dblack@wobblini.net> writes:

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


Mark J. Reed

11/29/2003 6:29:00 PM

0

On Sun, Nov 30, 2003 at 02:01:39AM +0900, Yukihiro Matsumoto wrote:
> * ../... in condition
> * regex literal in condition

What does "condition" refer to here? Just the expression of an
if/while/unless, or also the 'when' expression in a case? I don't see
any reason to lose when /regex/, since it quite orthogonally calls
=== with the case argument . . .

-Mark

ptkwt

11/29/2003 7:00:00 PM

0

In article <1070125296.186134.15652.nullmailer@picachu.netlab.jp>,
Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
>Hi,
>
>In message "anything disappearing from Ruby for 2.0?"
> on 03/11/29, "David A. Black" <dblack@wobblini.net> writes:
>
>|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

Josef 'Jupp' Schugt

11/30/2003 12:25:00 AM

0

Hi!

* Yukihiro Matsumoto; 2003-11-29, 21:58 UTC:
> In message "anything disappearing from Ruby for 2.0?"
> on 03/11/29, "David A. Black" <dblack@wobblini.net> writes:
>
> |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
--
begin SPAM-POLICY.txt.vbs
if msg.size > 100 kB or msg.sender.is_spammer or msg.text.is_spam
discard message
end

Michael Campbell

11/30/2003 1:09:00 AM

0

Yukihiro Matsumoto wrote:

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





Florian Gross

11/30/2003 2:35:00 AM

0

Yukihiro Matsumoto wrote:

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

11/30/2003 3:17:00 AM

0

On Sunday 30 November 2003 03:34 am, Florian Gross wrote:
> 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



Ferenc Engard

11/30/2003 3:49:00 AM

0

> 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


David Garamond

11/30/2003 5:09:00 AM

0

Ferenc Engard wrote:
>>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?

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.

--
dave