The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Function Call

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Function Call Posted: Feb 20, 2005 3:21 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Function Call
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

Translated from matz blog, 2005-02-18:

There is no breathing space because I had a deadline for periodical article. On the rebound, I contemplated Ruby. I suppose that I’m filled with pleasure in this time.

Python emulates OOP by being based on Function and Record, but Ruby’s Function is an emulation based on OOP. Therefore it’s not cool when we call lambda.

We need the ”.call”.

    f = lambda{|x| p x}
    f.call(12)

I wanna write it like this.

    f = lambda{|x| p x}
    f(12)

On this new rule,

  • When the name of something like function is a local variable, it apply a “call” to the variable.

What do you think?

Actually, I tried it before, but I failed for:

  • I used the special method “()” instead of “call”.
  • I tried to support that “foo.bar(12)” means “foo.bar.().call(12)”.

The new way’s fault is that a method can’t called if a local variable has a same name. There is no matter usually, but there’s a case that it’s frequently duplicated like “p” method. Should I prepare the way to avoid?

Read: Function Call

Topic: Process.getrusage Previous Topic   Next Topic Topic: Installing Lighttpd 1.3.10 on OSX

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use