[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: [ANN] MacRuby

Yukihiro Matsumoto

2/28/2008 9:52:00 PM

Hi,

In message "Re: [ANN] MacRuby"
on Fri, 29 Feb 2008 05:56:41 +0900, "Laurent Sansonetti" <laurent.sansonetti@gmail.com> writes:

|> duck.foo(1, bar: 2) # mapped to foo:bar: what does an
|> instance of C do with this?
|
|Here, MacRuby will check if duck responds to foo:bar:. If true, this
|message is sent with 1 and 2 as arguments. If not true, the foo
|message is sent instead with 1 and {:bar => 2} as arguments.
|
|If you're working with pure Ruby objects, the second code path should
|always be taken. Unless you define foo:bar: in your Ruby class.
|
|Note that the key:value syntax to describe a hash pair is available in
|vanilla 1.9.

I still think having dedicated syntax for Objective-C call is better
than overriding normal call.

duck.foo: 1 bar: 2

or

duck.foo: 1, bar: 2

maybe? I am not sure if the parser allows this or not yet.

matz.

2 Answers

Laurent Sansonetti

2/28/2008 11:05:00 PM

0

On Thu, Feb 28, 2008 at 1:51 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: [ANN] MacRuby"
>
> on Fri, 29 Feb 2008 05:56:41 +0900, "Laurent Sansonetti" <laurent.sansonetti@gmail.com> writes:
>
> |> duck.foo(1, bar: 2) # mapped to foo:bar: what does an
> |> instance of C do with this?
> |
> |Here, MacRuby will check if duck responds to foo:bar:. If true, this
> |message is sent with 1 and 2 as arguments. If not true, the foo
> |message is sent instead with 1 and {:bar => 2} as arguments.
> |
> |If you're working with pure Ruby objects, the second code path should
> |always be taken. Unless you define foo:bar: in your Ruby class.
> |
> |Note that the key:value syntax to describe a hash pair is available in
> |vanilla 1.9.
>
> I still think having dedicated syntax for Objective-C call is better
> than overriding normal call.
>
>
> duck.foo: 1 bar: 2
>
> or
>
>
> duck.foo: 1, bar: 2
>
> maybe? I am not sure if the parser allows this or not yet.
>

I have been thinking about this too, but I personally believe that it
doesn't reveal very pretty when messaging Objective-C methods with
only one argument.

duck.foo: 1

But maybe we will switch to it soon, because it's more consistent with
Objective-C (no potential ambiguities). But it doesn't feel very Ruby.

Laurent

George Plimpton

6/19/2012 4:03:00 AM

0

On 6/18/2012 8:16 PM, Too_Many_Tools wrote:
> On Jun 18, 3:44 am, "Something Smells" <did-he-...@barackobama.com>
> wrote:
>> Feynman, of Feynman diagrams fame, wasn't accepted at Columbia -
>> so he went to MIT, then Princeton.
>>
>> Obama is far dumber than Feynman.
>>
>> How exactly did Barack Obama get into Columbia?
>
> In a car...or maybe a bus...or maybe he walked.

He got in as an affirmative action admit.