Suggestion: swap name of "puts" and "print" and rename "puts" to "put_s"

I recently came across an experimental language which attempted to
combine ruby with static type inference from Haskell.

The author called it 'merd.'

Je ne sais pas s'il exprimait son avis de la valeur de l'idée même.

···

On 3/27/07, John Joyce <dangerwillrobinsondanger@gmail.com> wrote:

uhoh, I smell a new dialect of Ruby....
Ryiddish,
  or
Riddish?
  or
Rubish?

futz

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

irb(main):006:0> $_ = "abcdef"
=> "abcdef"
irb(main):007:0> puts "xxx" if /abc/
(irb):7: warning: regex literal in condition
xxx
=> nil
irb(main):008:0> puts "xxx" if /ghi/
(irb):8: warning: regex literal in condition
=> nil

Ugh. So the rule which says "anything which is not 'nil' or 'false' is true"
is broken in this construct, and this is just to make ruby more perlish.

Hmm. Thinking about this a bit more: since this applies only to regexp
*literals*,

   do_something if /foo/

would not be of any use if it were semantically equivalent to

   do_something if true

So I started thinking along the lines of: instead of using global variable
$_ as a kind of temporary register to pass data between methods, how could
this construct be made more Rubyish? For example, like a case statement,
"if /foo/" could translate to "if /foo/ === self" ?

But then I realised: perhaps this is all just a marketing scam. Maybe $_ and
friends exist in the language, not because they have any real use, but just
to sucker in Perl programmers. They see them there, and think "great, this
is like Perl, I'll give Ruby a try". Once they're hooked, they won't use
them any more than the rest of us do.

If that's true, the construct clearly *has* to use $_ to fulfil its purpose
:slight_smile:

Regards,

Brian.

Hi --

> irb(main):006:0> $_ = "abcdef"
> => "abcdef"
> irb(main):007:0> puts "xxx" if /abc/
> (irb):7: warning: regex literal in condition
> xxx
> => nil
> irb(main):008:0> puts "xxx" if /ghi/
> (irb):8: warning: regex literal in condition
> => nil
>
> Ugh. So the rule which says "anything which is not 'nil' or 'false' is true"
> is broken in this construct, and this is just to make ruby more perlish.

Hmm. Thinking about this a bit more: since this applies only to regexp
*literals*,

   do_something if /foo/

would not be of any use if it were semantically equivalent to

   do_something if true

When I first saw this:

  irb(main):001:0> puts "yes" if a = 1
  (irb):1: warning: found = in conditional, should be ==

I found it annoyingly micromanaging -- until I saw that it only
happened with literals, and then I realized that it was being very
shrewd. It's interesting, then, that this non-construct can be used
to do the $_ thing. I wonder whether other cases, like if a = 1, are
going to pressed into service :slight_smile: I hope not; I think the fact that
the regex one warns you and then goes ahead and does something other
than what it's warning you against suggests it could get pretty ugly.

So I started thinking along the lines of: instead of using global variable
$_ as a kind of temporary register to pass data between methods, how could
this construct be made more Rubyish? For example, like a case statement,
"if /foo/" could translate to "if /foo/ === self" ?

But then I realised: perhaps this is all just a marketing scam. Maybe $_ and
friends exist in the language, not because they have any real use, but just
to sucker in Perl programmers. They see them there, and think "great, this
is like Perl, I'll give Ruby a try". Once they're hooked, they won't use
them any more than the rest of us do.

If that's true, the construct clearly *has* to use $_ to fulfil its purpose
:slight_smile:

I'd love to see some of the Perl stuff disappear, and it's perenially
in the Ruby TODO file. I can hardly think of a case where I've seen
anyone use $_ in Ruby.

David

···

On 3/25/07, Brian Candler <B.Candler@pobox.com> wrote:

--
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black\)
   (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf\)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

I came to Ruby from Perl, and the $_ et al. definitely hooked me. But I quickly drank the Kool-Aid and I haven't used the $_ in years.

--be

···

On Mar 25, 2007, at 5:31 PM, David A. Black wrote:

On 3/25/07, Brian Candler <B.Candler@pobox.com> wrote:

So I started thinking along the lines of: instead of using global variable
$_ as a kind of temporary register to pass data between methods, how could
this construct be made more Rubyish? For example, like a case statement,
"if /foo/" could translate to "if /foo/ === self" ?

But then I realised: perhaps this is all just a marketing scam. Maybe $_ and
friends exist in the language, not because they have any real use, but just
to sucker in Perl programmers. They see them there, and think "great, this
is like Perl, I'll give Ruby a try". Once they're hooked, they won't use
them any more than the rest of us do.

If that's true, the construct clearly *has* to use $_ to fulfil its purpose
:slight_smile:

I'd love to see some of the Perl stuff disappear, and it's perenially
in the Ruby TODO file. I can hardly think of a case where I've seen
anyone use $_ in Ruby.