[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Confusion Over Keyword Arguments

Berger, Daniel

3/2/2006 10:02:00 PM

> -----Original Message-----
> From: list-bounce@example.com
> [mailto:list-bounce@example.com] On Behalf Of E. Saynatkari
> Sent: Thursday, March 02, 2006 2:22 PM
> To: ruby-talk ML
> Subject: Re: Confusion Over Keyword Arguments
>
>
> Daniel Berger wrote:
> > Yukihiro Matsumoto wrote:
> >>
> >>
> >> foo(1, foo:3) # (a=1, b={:foo=>3}) or (a=1,b=0,c=[{:foo=>3}])?
> >
> > Error. There's no 'foo' parameter. Passing a literal hash would
> > require {}.
> >
> >> foo(1, 2, 8, c:5) # c={:c=>5}) or c=[8,{:c=>5}] or error?
> >
> > Hm. Either an error or c = [5], depending on whether or
> not your want
> > to
> > declare that, once a positional is used, there's no going
> back after the
> > fact.
> >
> >> args = [1, {:b=>2, foo=>5}]
> >> foo(*args) # (a=1,b={:b=>2, foo=>5}) or
> (a=1,b=2,c=[{:foo=>5}])?
> >
> > a = 1, b = {:b=>2, foo=>5}, since you've passed a literal hash.
> >
> > Here's the latest test case we had for Sydney. Note that Sydney
> > assumes
> > that
> > all method arguments automatically become keyword
> arguments. There's no
> > syntax
> > for explicitly declaring that a given method parameter is a valid
> > keyword argument.
> >
> > For the kids following along at home, also see
> >
> http://redhanded.hobix.com/inspect/namedParametersArenTTheyA...
> > ml
> > for
> > further discussion on the subject.
> >
> > Regards,
> >
> > Dan
>
> Slightly off-topic but I found this part curious:
>
> > # You can use named parameters, using the name of the parameter
> defined in
> > # in the method itself. It must be the name of the parameter,
> followed by
> > # a colon, followed by the value. Spaces between the parameter
> name, colon
> > # and value are not allowed.
>
> Why is this? foo: bar would seem to be more legible with the
> added benefit of no confusion with the scope operator :: nor Symbols.
>
> Your testcases do not seem to cover the scope completely and
> Symbols are not included at all. Maybe add something like
>
> def test_corner_cases()
> # Symbols
> assert_nothing_raised {@foo.bar x:1, y:2, z::symbol}
>
> # Scopes
> assert_nothing_raised {@foo.bar A::B, y:2, z:3}
> assert_nothing_raised {@foo.bar x:1, y:2, z:::Object}
>
> assert_nothing_raised{ @foo.bar(z:1, x:2, y:3) }
> end # test_corner_cases
>
> To cover those.

Yes, I think this is one of the reasons we started leaning towards using
'=' instead. Maybe we should stick with '=>' - no issues with symbols
or assignment, and people are used to it.

Regards,

Dan


2 Answers

Yuu

3/2/2006 10:36:00 PM

0

Berger, Daniel wrote:
>> >>
>> > to
>> > Here's the latest test case we had for Sydney. Note that Sydney
>> http://redhanded.hobix.com/inspect/namedParametersArenTTheyA...
>> > # You can use named parameters, using the name of the parameter
>> Your testcases do not seem to cover the scope completely and
>> assert_nothing_raised{ @foo.bar(z:1, x:2, y:3) }
>> end # test_corner_cases
>>
>> To cover those.
>
> Yes, I think this is one of the reasons we started leaning towards using
> '=' instead. Maybe we should stick with '=>' - no issues with symbols
> or assignment, and people are used to it.

Both problems should be fixed by mandating that there
be a space between foo: and its argument :) What other
parsing issues that might bring is different.

> Regards,
>
> Dan


E

--
Posted via http://www.ruby-....


Tony @ GLM

7/15/2010 11:50:00 PM

0

On Jul 15, 1:38 am, "Tony @ GLM" <cl...@greatlakesmodular.com> wrote:
> On Jul 15, 12:52 am, "Fred Kemper" <pbgar...@davlin.net> wrote:
>
> >  Helps if you post what game it fits....
>
> > --
> > Fred
> > TX
> > CARGPB#8
> > ******************
>
> Well it can probably be found in some of the following games:
>
> Comet
> Sorcerer
> Space Shuttle
>
> It wasn't used on every one of them as it was apparently a late System
> 9 production run throw-in.
>
> It can also be found in the following shuffle alleys:
>
> Alley Cats Shuffle
> Gold Mine Shuffle
> Shuffle Inn and SI Deluxe
> Strike Zone
> Top Dawg
>
> Tony
> www.greatlakesmodular.com- Re-Engineered Pinball Parts!

I got the hookup, thanks everyone!

Tony
www.greatlakesmodular.com - Re-Engineered Pinball Parts!