Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby Warnings

Reply
Thread Tools

Ruby Warnings

 
 
Chris Pine
Guest
Posts: n/a
 
      02-12-2004
I have been getting complaints that the code in my tutorial generates
warnings (just in chapter 5). So, I'm looking into it, and I notice the
following:

irb(main):001:0> puts 'hello '.+ 'world'
(irb):1: warning: parenthesize argument(s) for future version
hello world
=> nil
irb(main):002:0> puts 'hello ' + 'world'
hello world
=> nil

So why the warning? It's a shame, because the code won't be nearly as
readable for newcomers to Ruby, littered as it will have to be with
parenthases.

Also, can we stop switching from "syntax error" to "parse error" and back?

Chris

PS: I tried sending this to the ML instead of the newsgroup, and nothing
happened. Not even a message telling me "no, thank you, chris". What's up?


 
Reply With Quote
 
 
 
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      02-12-2004
Hi,

In message "Ruby Warnings"
on 04/02/12, "Chris Pine" <(E-Mail Removed)> writes:

|I have been getting complaints that the code in my tutorial generates
|warnings (just in chapter 5). So, I'm looking into it, and I notice the
|following:
|
| irb(main):001:0> puts 'hello '.+ 'world'
| (irb):1: warning: parenthesize argument(s) for future version
| hello world
| => nil
| irb(main):002:0> puts 'hello ' + 'world'
| hello world
| => nil
|
|So why the warning?

'hello '.+ 'world'

is a form of "recv.message arg", i.e. parentheses around argument are
omitted apparently, and the expression itself is an argument to
"puts". When you use method call as argument, don't omit parentheses,
no exception.

| It's a shame, because the code won't be nearly as
|readable for newcomers to Ruby, littered as it will have to be with
|parenthases.

I think newcomers can easily be confused by a dot before plus.

matz.


 
Reply With Quote
 
 
 
 
Mauricio Fernández
Guest
Posts: n/a
 
      02-12-2004
On Thu, Feb 12, 2004 at 11:44:15PM +0900, Yukihiro Matsumoto wrote:
|So why the warning?
>
> 'hello '.+ 'world'
>
> is a form of "recv.message arg", i.e. parentheses around argument are
> omitted apparently, and the expression itself is an argument to
> "puts". When you use method call as argument, don't omit parentheses,
> no exception.


This case is a bit unfortunate:

def foo(a); a end; puts(foo "a")
-:1: warning: parenthesize argument(s) for future version

--
_ _
| |__ __ _| |_ ___ _ __ ___ __ _ _ __
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

oh okay. my mistake.

Yafcot:atj(*),

mark

* Yet another fool coming over this: according to joey
-- http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby 1.8.4 gives warnings where ruby 1.8.2 doesn't - how to disable? Asfand Yar Qazi Ruby 1 03-19-2006 11:09 AM
Differing signedness warnings when compiling ruby-odbc. Ben Gribaudo Ruby 0 01-09-2006 03:21 PM
Ruby + yaml = warnings??? Kurt V. Hindenburg Ruby 3 12-12-2005 03:31 PM
use warnings; and use Warnings; give different results Ted Sung Perl Misc 1 08-30-2004 10:22 PM
Ruby 1.8.1 and forwardable warnings Daniel Berger Ruby 1 03-05-2004 01:52 AM



Advertisments