Ruby Warnings

Discussion in 'Ruby' started by Chris Pine, Feb 12, 2004.

  1. Chris Pine

    Chris Pine Guest

    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?
     
    Chris Pine, Feb 12, 2004
    #1
    1. Advertising

  2. Hi,

    In message "Ruby Warnings"
    on 04/02/12, "Chris Pine" <> 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.
     
    Yukihiro Matsumoto, Feb 12, 2004
    #2
    1. Advertising

  3. 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
    --
     
    Mauricio Fernández, Feb 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Berger

    Ruby 1.8.1 and forwardable warnings

    Daniel Berger, Mar 5, 2004, in forum: Ruby
    Replies:
    1
    Views:
    109
  2. Kurt V. Hindenburg

    Ruby + yaml = warnings???

    Kurt V. Hindenburg, Dec 12, 2005, in forum: Ruby
    Replies:
    3
    Views:
    213
    Edwin van Leeuwen
    Dec 12, 2005
  3. Ben Gribaudo
    Replies:
    0
    Views:
    223
    Ben Gribaudo
    Jan 9, 2006
  4. Asfand Yar Qazi
    Replies:
    1
    Views:
    153
    Florian Groß
    Mar 19, 2006
  5. Ted Sung
    Replies:
    1
    Views:
    336
    Sherm Pendley
    Aug 30, 2004
Loading...

Share This Page