"Mark Hubbart" <discordantus / gmail.com> schrieb im Newsbeitrag 
news:de63abca05011415224d4c29a1 / mail.gmail.com...
> Hi,
>
> I think I probably was somewhat unclear in my other post. I wasn't
> arguing for or against your idea (for the most part), I was going off
> it and thinking up a related idea... I guess it was actually pretty
> off topic.

Ah, ok, I see much clearer now.  Thanks for clarifying.

> On Sat, 15 Jan 2005 05:06:13 +0900, Robert Klemme <bob.news / gmx.net> 
> wrote:
>>
>> "Mark Hubbart" <discordantus / gmail.com> schrieb im Newsbeitrag
>> news:de63abca0501141100154206a8 / mail.gmail.com...
>>
>> > I do this to make sure I'm allowing for maximum flexibility, or when
>> > working with other's code, to find out what the actual requirements
>> > are :)
>>
>> Well, then you'll learn that your instance must implement to_int.  Same 
>> as
>> if someone had coded that directly in the method.  I don't see this as an
>> argument against my suggested shortcut syntax, because that mainly 
>> affects
>> the *writer* of a method - not the *caller*.
>
> My only argument against the shortcut syntax is that I can't see how
> often it could be used, except to simulate static typing. I suspect
> that adding a feature like this would encourage the use of static
> typing in methods.

Ok, then we need a poll.  Or we should dig into Ruby's std lib to see how 
often these methods are called.

> In your example method, you called #to_int on an object that you were
> just going to call #times on. This doesn't guarantee that you will get
> an integer,

Of course.

> and makes it difficult for others to use duck typing in
> code that interfaces with yours.

The same holds true if the idiom is used inside the method body.

> In fact, if they need the
> functionality, then the have to resort to some hack like this:
>
> obj = ObjectThatImplementsTimes.new
> wrapper = Object.new
> class << wrapper;self;end.__send__(:define_method, :to_int){obj}
>
> A very ugly hack, just to re-allow duck typing.

The invocation of to_int is already and application of duck typing.

<snip/>

>> > Second, I'm not sure about the syntax. It would work
>> > (it currently give a parse error), but I think something better and
>> > more self-explanatory could be found.
>>
>> Sure.  I'm very open here.  I think the selection of "." as separator was
>> not good.  We can change that any time.  But the real issue for me is, 
>> does
>> this make sense independend of syntax?
>
> I still think that this is, for the most part, an implementation of
> static typing. It may just be me, but I very rarely use to_str,
> to_int, etc, in my code. The only time I do is when I absolutely have
> to have those particular classes. Which is so uncommon for me, I can't
> think of the last time I used it. But as I said, I may very well be in
> the minority here.

We need figures here.  If I find the time this weekend I'll try to come up 
with statistics.

    robert