anything disappearing from Ruby for 2.0?

G

George Moschovitis

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

i agree, i dont use them for big projects, but they are usefull for
simple administration scripts.

George Moschovitis
www.navel.gr
 
M

Michael Campbell

Yukihiro said:
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.

That would work for the IO case, but I have used many times the ".." as
a flip-flop NOT relating to lines matching a regex.

I think this is not the best thing for consideration of removal; I
haven't seen yet anyone get confused over it.
 
C

Charles Hixson

Yukihiro said:
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.
I frequently have the need for a "between" operator, and it's quite
convenient to have it built into the language in such a flexible way.
OTOH, I don't know what the costs are. OTOH, if you are only discussing
the removal of pattern ranges...well, I use that much less often, but
it's certainly more legible than any replacement that I can think of.
(And the from_to operator would seem to need to be a component of
Iterator rather than IO.)
 
N

Nathaniel Talbott

I think this is not the best thing for consideration of removal; I
haven't seen yet anyone get confused over it.

To throw in an opinion on the other side, I find this construct very
confusing, and am glad to see it go. I've never used it, and never felt
a lack. Plus, I fear having to explain it to newcomers.

Just my $0.02,


Nathaniel

<:((><
 
J

Josef 'Jupp' SCHUGT

Hi!

* Ferenc Engard; 2003-11-30, 13:06 UTC:
* * Yukihiro Matsumoto
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 cannot see anything that requires one-liners besides showing off.
They are not even fun in most cases.
Or, maybe to not defining them by default, but enabling them with a
cmdline switch?

Matz pointed out that he also wants to remove the "require "English"'
equivalents. I therefore don't think that he wants to remove the
variables because they look ugly but because they obfuscate code.

I think that expressing algorithms with as few characters as possible
should always be a side-effect of the syntax of a programming
language resulting from 'making simple things simple and complicated
things possible' but not a design principle of its own.

Josef 'Jupp' Schugt
 
I

Ian Hobson

In message said:
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.
Indeed. On some keyboards the short name uses characters that do not
have a key stroke on some language variant keyboards.

I have no key for the short form of $PREMATCH so please can that
remain.

Regards

Ian
 
I

Ian Macdonald

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 would like to lend my voice to the choir in favour of keeping them.

I would never use $_ in code that I expected to re-use, but for writing
one-liners on the command-line, it's indispensible and avoids longer
constructs that add no value to disposable code.

In my opinion, these useful shortcuts are one of the things that make
Ruby such a useful language for system administration, moreso than
Python, for example. I'd like to continue to use Ruby for everything and
not have to resort to using Perl again for my one-liner work.

Ian
--
Ian Macdonald | Toothpaste never hurts the taste of good
System Administrator | scotch.
(e-mail address removed) |
http://www.caliban.org |
|
 
B

Bill Kelly

From: "Josef 'Jupp' SCHUGT said:
* Ferenc Engard; 2003-11-30, 13:06 UTC:
* * Yukihiro Matsumoto

I cannot see anything that requires one-liners besides showing off.
They are not even fun in most cases.

I use Ruby one-liners from the command line somewhat frequently,
and they *are* fun, and they have little to do with showing off... :)

More details at: http://ruby-talk.org/81834

I WOULD NOT like to lose this powerful facet of Ruby...


Regards,

Bill
 
D

David Garamond

Chris said:
[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.

There's always Python for you. :)

There are lots of Perl programmers, and Pythonisms in Python (obviously
:) are a major turn off for them. I am one of them. When I found Ruby,
I am delighted that many "useful" things in Perl are also present in Ruby.

Also, not all Perlisms are disgusting or hacks. Regexp
literals/operators, for example (although they don't come originally
from Perl) really help cleanliness of appearance. In languages that must
use strings to express regexp, you can see the proliferation of
backslashes or string concatenation that looks ugly.

Anyway, Ruby is Matz' language, and Matz _is/was_ a Perl programmer. In
fact, he wanted a better Perl for him when designing Ruby.
 
D

David Garamond

Josef said:
I cannot see anything that requires one-liners besides showing off.
They are not even fun in most cases.

I find the ability to write one-liners _amazingly_ useful. Perhaps you
don't use shell/command-line interface much. But many, many Unix/Linux
users do most of their stuffs in shell daily. And using a combination of
Unix commands sometimes are just not powerful/easy/portable enough. I
use Perl & Ruby one-liners for all things, from renaming a bunch of
files according to some string/regex operation (e.g. changing all
".tar.gz" to ".tgz"), manipulating file contents (e.g. neutralizing
"evil" HTML pages), downloading recursively but with some complex rules
that wget can't do, etc.

Btw, I even have a text file where I store hundreds of Perl & Ruby
one-liners which I can just copy paste to the shell window whenever I
needs them. It beats having hundreds of script files which I don't know
how to name properly.
Matz pointed out that he also wants to remove the "require "English"'
equivalents.

This one I agree. Nobody in the world seems to use 'require "English"'
in Ruby or 'use English' in Perl. Those using $_, $/, etc will use them
in the short form. Those hating them will not use them anyway, not even
the pretty English names.
 
T

Thien Vuong

Michael said:
That would work for the IO case, but I have used many times the ".." as
a flip-flop NOT relating to lines matching a regex.

I think this is not the best thing for consideration of removal; I
haven't seen yet anyone get confused over it.
I concur with this opinion. Also, I sometimes uses multiple pattern
ranges in a scan loop so not sure if the IO#from_to would be able to do
the same. I never need this functionality before until learned from
PERL and it made lots of text scanning code simpler by not having to
maintain state variables.
 
T

Thien Vuong

Michael said:
That would work for the IO case, but I have used many times the ".." as
a flip-flop NOT relating to lines matching a regex.

I think this is not the best thing for consideration of removal; I
haven't seen yet anyone get confused over it.
I concur with this opinion. Also, I sometimes uses multiple pattern
ranges in a scan loop so not sure if the IO#from_to would be able to do
the same. I never need this functionality before until learned from
PERL and it made lots of text scanning code simpler by not having to
maintain state variables.
 
D

Dan Doel

Michael said:
That would work for the IO case, but I have used many times the ".."
as a flip-flop NOT relating to lines matching a regex.

I think this is not the best thing for consideration of removal; I
haven't seen yet anyone get confused over it.


This isn't nearly as concise as ".." notation, but:

module Enumerable
def range(from, to)
inject(false) do |bool, val|
bool ||= from === val
yield val if bool
bool &&= !(to === val)
end
end
end

[0,-1,34,8,9,0,1,2,3,4,5,6].range(-1,1) do |i| puts i end

Which works for anything with #each. You could add an option for "..."
behavior (if it's different. I can't remember).

Isn't the problem with ".." that it's matching implicitly against Perl
style variables? If you eliminate those, then
../... has to be replaced by either a message send to an object that can
enumerate the values, or by a loop that
handles things more explicitly.

- Dan
 
M

Martin DeMello

David Garamond said:
I find the ability to write one-liners _amazingly_ useful. Perhaps you
don't use shell/command-line interface much. But many, many Unix/Linux
users do most of their stuffs in shell daily. And using a combination of
Unix commands sometimes are just not powerful/easy/portable enough. I
use Perl & Ruby one-liners for all things, from renaming a bunch of
files according to some string/regex operation (e.g. changing all
".tar.gz" to ".tgz"), manipulating file contents (e.g. neutralizing
"evil" HTML pages), downloading recursively but with some complex rules
that wget can't do, etc.

Sorry to harp on about this, but given the number of people chiming in
in support of one-liners, I really don't understand the general
indifference/antipathy to RCR #164. I know there are ways to hack it
using a wrapper around the ruby interpreter, but then, there are ways to
hack most things.

martin
 
P

Paul Brannan

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 is the Prec module?

irb(main):001:0> Prec
NameError: uninitialized constant Prec
from (irb):1
irb(main):002:0>

[pbrannan@zaphod tmp]$ irb-1.8
irb(main):001:0> Prec
NameError: uninitialized constant Prec
from (irb):1
irb(main):002:0>

Paul
 
M

Michael campbell

Dan Doel wrote:

Isn't the problem with ".." that it's matching implicitly against Perl
style variables?

In the "/foo/ .. /bar/" case, yes, but that's because /xxx/ does, not "..".

You could just as easily:

while (line = $stdin.gets)

do_something_useful(line) if (line =~ /foo/ .. line =~ /bar/)
# other magic happens here

here_is_something_else(some_other_var, 2)
while (some_message(n) .. another_message(x))

end


Nothing perly there. What Matz is proposing (if I read it right, and I
might not have) is to remove the ability to use .. as a scalar flip-flop
as a boolean. (Or did I misread that?)
 
G

Gavin Sinclair

[...]
Matz pointed out that he also wants to remove the "require "English"'
equivalents.
This one I agree. Nobody in the world seems to use 'require "English"'
in Ruby or 'use English' in Perl. Those using $_, $/, etc will use them
in the short form. Those hating them will not use them anyway, not even
the pretty English names.

The English equivalents are a good lookup guide as to what on earth
the snoopy-swearing variables mean :)

Gavin
 
C

Carlos

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

Hi :) Here's another idea:

1) Make #.. a method (Integer#.. creates ranges, for example)

2) Make a shortcut to proc {...} (maybe "&{"? Anything, I don't know)

3) Define Proc#.. to work as a flip-flop

4) while &{ line =~ /abc/ }..&{ line =~ /def/ }

Not as easy as before, but almost...

What do you think?
 
Y

Yukihiro Matsumoto

Hi,

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

|Hi :) Here's another idea:
|
|1) Make #.. a method (Integer#.. creates ranges, for example)
|
|2) Make a shortcut to proc {...} (maybe "&{"? Anything, I don't know)
|
|3) Define Proc#.. to work as a flip-flop
|
|4) while &{ line =~ /abc/ }..&{ line =~ /def/ }
|
|Not as easy as before, but almost...
|
|What do you think?

I like the basic idea. the "shortcut notation" would be a key. I
couldn't think of a good one for years. But someone might be able to.

matz.
 
Y

Yukihiro Matsumoto

Hi,

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

|> * Prec module
|
|What is the Prec module?

Actually, it's Precision module. Don't ask me what it is.

matz.
 

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,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top