Anything disappearing from Ruby for 2.0?

Hi,

···

In message “Re: anything disappearing from Ruby for 2.0?” on 03/12/01, Paul Brannan pbrannan@atdesk.com writes:

  • Prec module

What is the Prec module?

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

						matz.

Hi,

···

In message “Re: anything disappearing from Ruby for 2.0?” on 03/11/30, David Garamond lists@zara.6.isreserved.com writes:

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.

Hi,

···

In message “Re: anything disappearing from Ruby for 2.0?” on 03/11/30, “T. Onoma” transami@runbox.com writes:

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.

Yukihiro Matsumoto wrote:

Hi,

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.

···

In message “Re: anything disappearing from Ruby for 2.0?” > on 03/11/30, Michael Campbell michael_s_campbell@yahoo.com writes:

Yukihiro Matsumoto wrote:

Hi,

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

···

In message “Re: anything disappearing from Ruby for 2.0?” > on 03/11/30, Michael Campbell michael_s_campbell@yahoo.com writes:

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

···

In message 1070189641.176593.21615.nullmailer@picachu.netlab.jp, Yukihiro Matsumoto matz@ruby-lang.org writes

Hi,

In message “Re: anything disappearing from Ruby for 2.0?” > on 03/11/30, “Josef ‘Jupp’ SCHUGT” jupp@gmx.de writes:

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


Ian - posting to a Newsgroup. Please remove everything to reply.

Hi –

Hi!

  • Ferenc Engard; 2003-11-30, 13:06 UTC:
    • Yukihiro Matsumoto

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.

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

[…]

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.

I think you’re assuming that ‘one-liner’ means deliberately minimized
code (as in ‘code golf’), but it doesn’t have to. Most ‘code golf’
involves one-liners, but not all one-liners involve code golf :slight_smile:

David

···

On Mon, 1 Dec 2003, Josef ‘Jupp’ SCHUGT wrote:


David A. Black
dblack@wobblini.net

Hi,
I would disagree. While I am more apt to use perl or gawk for one liners
there have been several times it has been nice to use ruby for oneliners.
They aren’t just for showing off, they are often nice for quickly filtering
a file or something, and I have never bothered to learn sed over simple
replacements so one liners become quite useful in this regard. While most
of the one liners I have written haven’t required the special characters to
do this I don’t think dismissing one liners as simply for showing off is at
all fair.

Long term scripts shouldn’t require one liners but for quickly scanning for
some info from a file or some basic filter one liners are what makes UNIX so
incredibly useful to programmers.

Charlie

···

-----Original Message-----
From: Josef ‘Jupp’ SCHUGT [mailto:jupp@gmx.de]

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

for i in $(seq 1 9); do
rm /bin/cat
done

  • Ferenc Engard; 2003-11-30, 13:06 UTC:
    • Yukihiro Matsumoto

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.

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… :slight_smile:

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

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

Regards,

Bill

···

From: “Josef ‘Jupp’ SCHUGT” jupp@gmx.de

Chris Uppal wrote:

[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. :slight_smile:

There are lots of Perl programmers, and Pythonisms in Python (obviously
:slight_smile: 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.

···


dave

Josef ‘Jupp’ SCHUGT wrote:

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.

···


dave

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 :slight_smile: 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?

Hi!

  • Yukihiro Matsumoto; 2003-12-01, 21:55 UTC:
    [candidates for deletion]

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

This is what the rubydoc documentation has on it (I did en passent
correct some nihonisms like singular/plural issues and ‘k’ in place
of ‘c’ to make it more readable):

Precision is a Mix-in for concrete numerical classes with
precision. Here, `precision’ means the fineness of approximation
of a real number, so, this module should not be included into
non-subset of real, e.g. abstract numerical, complex, matrix.

induced_from(number)

Creates an object which is converted from number. Since it by
default raises TypeError, redefine before use. Note that a use of
prec in a redefinition may causes an infinite loop.

prec(class)

Converts self into an instance of class. By default, prec invokes
class.induced_from(self) and returns its value. So, if
class.induced_from doesn’t correspond to the class of self, it is
neccessary to redefine this prec.

prec_i

Returns an integer converted from self. It is equivalent to prec
(Integer).

prec_f

Returns a floating-point number converted from self. It is
equivalent to prec(Float).

According to me there is good reason not to remove that. In natural
sciences knowing the precision of values is as important as knowing
the values themselves (if not more important). To give an example:
The result of a computation is that a particle that according to
theory should have a rest mass of 0 has a rest mass of 1 eV(*). If
the imprecision of that value is 0.1 eV the result is strong evidence
that theory is wrong or that some mistake was made interpreting the
experiment. If the uncertainty is 2 eV the same value is in accord
with theory. The imprecision is partly introduced by uncertainties in
measurements but also by imprecisions of numerical representations of
real values.

(*) Precisely taken 1 eV is a mass energy equivalent (because of
Einstein’s E=mc^2 it makes perfect sense to express mass in terms
of energy, the difference is just some poportionality factor…)

Josef ‘Jupp’ Schugt

···


for i in $(seq 1 9); do
rm /bin/cat
done

Yukihiro Matsumoto wrote:

Hi,

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

i don’t know if $* is in this list, but i consider it extremely
intuitive to remember (also because it’s used in shell scripts AFAIK)
and also concise. actually i don’t know the alternative and i don’t want
to wonder if it’s all caps, with underscores or whatever…

i hope this one will stay.

emmanuel

···

In message “Re: anything disappearing from Ruby for 2.0?” > on 03/11/30, “Josef ‘Jupp’ SCHUGT” jupp@gmx.de writes:

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

-t0

···

On Sunday 30 November 2003 12:02 pm, Yukihiro Matsumoto wrote:

Hi,

In message “Re: anything disappearing from Ruby for 2.0?” > > on 03/11/30, “T. Onoma” transami@runbox.com writes:

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.

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

<:((><

···

On Nov 30, 2003, at 09:49, Michael Campbell wrote:

Ack, no more:

if (/foo/ … /bar/) ?

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

Michael Campbell wrote:

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

Michael Campbell wrote:

Yukihiro Matsumoto wrote:

Hi,

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.

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.

···

In message “Re: anything disappearing from Ruby for 2.0?” >> on 03/11/30, Michael Campbell michael_s_campbell@yahoo.com writes:

Michael Campbell wrote:

Yukihiro Matsumoto wrote:

Hi,

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.

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.

···

In message “Re: anything disappearing from Ruby for 2.0?” >> on 03/11/30, Michael Campbell michael_s_campbell@yahoo.com writes:

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

···

David Garamond lists@zara.6.isreserved.com wrote:

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.