[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Method.new - why not?

Yukihiro Matsumoto

2/4/2009 3:29:00 PM

Hi,

In message "Re: Method.new - why not?"
on Wed, 4 Feb 2009 15:20:21 +0900, Daniel Berger <djberg96@gmail.com> writes:

|Just a random thought that I think was inspired by several people on
|the list asking about getting the name of the method from within the
|method - why don't we have Method.new? In other words, what if this:
|
|def foo(x, y=1)
|end
|
|Was the equivalent of this?
|
|x = Method.new(:name => 'foo', :parameters => ['x', 'y'], :defaults =>
|{'y' => 1})
|Object.include(x) # or bind(x) or something

|Or is this totally stupid?

I don't think the idea itself is stupid at all, but I am afraid that
it doesn't go quite well with Ruby's Lisp-2 semantics. That idea
would shine better in Lisp-1-ish languages like Scheme or Python.

matz.

1 Answer

Julian Leviston

2/5/2009 1:37:00 AM

0

There's nothing to stop him writing a new class, say Message, that
exhibits this behaviour tho hey

Blog: http://random8.ze...
Learn rails: http://sensei.ze...

On 05/02/2009, at 2:29 AM, Yukihiro Matsumoto <matz@ruby-lang.org>
wrote:

> Hi,
>
> In message "Re: Method.new - why not?"
> on Wed, 4 Feb 2009 15:20:21 +0900, Daniel Berger <djberg96@gmail.com
> > writes:
>
> |Just a random thought that I think was inspired by several people on
> |the list asking about getting the name of the method from within the
> |method - why don't we have Method.new? In other words, what if this:
> |
> |def foo(x, y=1)
> |end
> |
> |Was the equivalent of this?
> |
> |x = Method.new(:name => 'foo', :parameters => ['x', 'y'], :defaults
> =>
> |{'y' => 1})
> |Object.include(x) # or bind(x) or something
>
> |Or is this totally stupid?
>
> I don't think the idea itself is stupid at all, but I am afraid that
> it doesn't go quite well with Ruby's Lisp-2 semantics. That idea
> would shine better in Lisp-1-ish languages like Scheme or Python.
>
> matz.
>