[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Seeking info on keyword parameters

Its Me

1/4/2005 10:14:00 AM

Will 2.0 make the names of keyword parameters available via reflection?

Sorry to ask this again, but it is really important for me. I decided years
ago that I much prefer

1) helper.move desk from: kitchen to: study using: trolley before: tomorrow
to
2) helper.move_from_to_using_before(desk, kitchen, study, trolley, tomorrow)
which is arguably somewhat better than
3) helper.move(desk, kitchen, study, trolley, tomorrow)

So I am very concerned about keyword parameter names being available to
reflection.

Separately but related: will keyword parameter names be treated as part of
the method names for method lookup, allowing a form of overloading?

Could anyone shed some light on the plans here? Thanks.


26 Answers

Yukihiro Matsumoto

1/4/2005 10:21:00 AM

0

Hi,

In message "Re: Seeking info on keyword parameters"
on Tue, 4 Jan 2005 19:16:33 +0900, "itsme213" <itsme213@hotmail.com> writes:

|Will 2.0 make the names of keyword parameters available via reflection?

Unlike your expectation, 2.0 keyword arguments will look like
Python's. They are like "named optional arguments", rather than
Smalltalk style method names.

matz.


gabriele renzi

1/4/2005 11:13:00 AM

0

Yukihiro Matsumoto ha scritto:
> Hi,
>
> In message "Re: Seeking info on keyword parameters"
> on Tue, 4 Jan 2005 19:16:33 +0900, "itsme213" <itsme213@hotmail.com> writes:
>
> |Will 2.0 make the names of keyword parameters available via reflection?
>
> Unlike your expectation, 2.0 keyword arguments will look like
> Python's. They are like "named optional arguments", rather than
> Smalltalk style method names.
>
> matz.

maybe I'm reading too much in this message, but did you left the idea of
having separated named arguments and default arguments ?

Florian Gross

1/4/2005 11:30:00 AM

0

Yukihiro Matsumoto wrote:

> Hi,

Moin.

> In message "Re: Seeking info on keyword parameters"
> on Tue, 4 Jan 2005 19:16:33 +0900, "itsme213" <itsme213@hotmail.com> writes:
>
> |Will 2.0 make the names of keyword parameters available via reflection?
>
> Unlike your expectation, 2.0 keyword arguments will look like
> Python's. They are like "named optional arguments", rather than
> Smalltalk style method names.

Still, could we not add a method to Method objects that gives us more
information about the method signature then just how many arguments it
expects? I think it would be nice if we could somehow get the names of
keyword and regular arguments and the default value. Maybe an Array of
[symbol, type, default] where type would be something like :regular,
:keyword, :grab, :block_grab, :keyword_grab or nil and default and
symbol nil if not appropriate. While we are at it we could also add
Method#mandatory_argc.

I think that information could be extracted from the Node tree on-demand
so it would not have an overhead unless it is really used.

Does this sound possible? Would it be worth the effort?

Yukihiro Matsumoto

1/4/2005 11:35:00 AM

0

Hi,

In message "Re: Seeking info on keyword parameters"
on Tue, 4 Jan 2005 20:16:34 +0900, gabriele renzi <rff_rff@remove-yahoo.it> writes:

|maybe I'm reading too much in this message, but did you left the idea of
|having separated named arguments and default arguments ?

I assume you are suggesting Smalltalk style

foo.move a from: b to: c

method invocation which mentioned by itsme. I'm not positive that it
fits in Ruby. How can I specify such a method by a symbol, for
example?

matz.


Its Me

1/4/2005 11:51:00 AM

0


"Florian Gross" <flgr@ccan.de> wrote in message
news:33vd54F45vujfU1@individual.net...
> Yukihiro Matsumoto wrote:
> > Unlike your expectation, 2.0 keyword arguments will look like
> > Python's. They are like "named optional arguments", rather than
> > Smalltalk style method names.

Thanks for the clarification regarding overloading, Matz. I can live with
this.

I'm not sure I got the answer to my first question: will the names be
available via reflection.

> Still, could we not add a method to Method objects

This is where I get a bit lost. This information belongs with UnboundMethod
objects, doesn't it? It would be fine to have indirect access to it via
Method objects.

> that gives us more
> information about the method signature then just how many arguments it
> expects? I think it would be nice if we could somehow get the names of
> keyword and regular arguments and the default value. Maybe an Array of
> [symbol, type, default] where type would be something like :regular,
> :keyword, :grab, :block_grab, :keyword_grab or nil and default and
> symbol nil if not appropriate. While we are at it we could also add
> Method#mandatory_argc.
>
> I think that information could be extracted from the Node tree on-demand
> so it would not have an overhead unless it is really used.
>
> Does this sound possible? Would it be worth the effort?

I would very much like what Florian proposes. Could it please be made
extensible so someone could add on other method and parameter meta-data they
found useful?


gabriele renzi

1/4/2005 12:01:00 PM

0

Yukihiro Matsumoto ha scritto:
> Hi,
>
> In message "Re: Seeking info on keyword parameters"
> on Tue, 4 Jan 2005 20:16:34 +0900, gabriele renzi <rff_rff@remove-yahoo.it> writes:
>
> |maybe I'm reading too much in this message, but did you left the idea of
> |having separated named arguments and default arguments ?
>
> I assume you are suggesting Smalltalk style
>
> foo.move a from: b to: c
>
> method invocation which mentioned by itsme. I'm not positive that it
> fits in Ruby. How can I specify such a method by a symbol, for
> example?
>
> matz.

sorry for being unclear.
I meant if you still think that arguments declared with "=" are
separated from argument declared with ":", :

def foo(a=10, b: 20)... end
foo(7, b: 40)

since you wrote "look like python" I hoped that you changed your mind by
allowing 'named' passing for all arguments:

def foo(a=10, b=20)
foo b: 40, a: 20

Florian Gross

1/4/2005 12:35:00 PM

0

itsme213 wrote:

>>Still, could we not add a method to Method objects
>
> This is where I get a bit lost. This information belongs with UnboundMethod
> objects, doesn't it? It would be fine to have indirect access to it via
> Method objects.

Well, I was talking about Methods in general e.g. both bound methods and
unbound methods. Currently the naming of the classes is a bit confusing.

> I would very much like what Florian proposes. Could it please be made
> extensible so someone could add on other method and parameter meta-data they
> found useful?

I don't think there's more meta-data than the above.

Its Me

1/4/2005 1:03:00 PM

0


"Florian Gross" <flgr@ccan.de> wrote in message
news:33vgveF4358soU1@individual.net...
> > I would very much like what Florian proposes. Could it please be made
> > extensible so someone could add on other method and parameter meta-data
they
> > found useful?
>
> I don't think there's more meta-data than the above.

Not built into Ruby, true. But an app might have its own meta-data, possibly
domain-specific. Perhaps things like param types, or data about how
parameters are interpreted by a method (e.g. "either a list of dates, or a
start date and a list of durations "), etc. A domain-specific Ruby could add
Class#methods to declare such things.


Florian Gross

1/4/2005 1:54:00 PM

0

itsme213 wrote:

>>>other method and parameter meta-data
>>I don't think there's more meta-data than the above.
>
> Not built into Ruby, true. But an app might have its own meta-data, possibly
> domain-specific. Perhaps things like param types, or data about how
> parameters are interpreted by a method (e.g. "either a list of dates, or a
> start date and a list of durations "), etc. A domain-specific Ruby could add
> Class#methods to declare such things.

I think that's outside the scope of the above request.

That aside I think custom meta-data should be implemented via custom
methods on method objects. This would be easier if method objects were
to be cached by Ruby.

Yukihiro Matsumoto

1/4/2005 2:31:00 PM

0

Hi,

In message "Re: Seeking info on keyword parameters"
on Tue, 4 Jan 2005 21:01:34 +0900, gabriele renzi <rff_rff@remove-yahoo.it> writes:

|I meant if you still think that arguments declared with "=" are
|separated from argument declared with ":", :

Ah, they will be separated (unlike Python).

matz.