Excerpts from Austin Ziegler's message of Mon Feb 02 18:26:44 +0200 2009:
> On Mon, Feb 2, 2009 at 10:31 AM, Berger, Daniel <Daniel.Berger / qwest.com> wrote:
> > If we're going to go that route, then we should bake it directly into
> > the method declaration:
> >
> >   def some_method(String param1) => Fixnum
> >   ...
> >   end
> >
> > Method "some_method" takes a single parameter, that should be a
> > String, and returns a Fixnum. Rdoc could handle this directly. Plus we
> > get metadata from the method declaration itself, instead of trying to
> > parse a comment system. I think there's greater potential for DBC with
> > this approach, too.

I think optional (or forced) typing is useful only in some cases.
It might be a necessary component for a restricted subset of Ruby
to allow more optimisations, as Charles intimates. (In Rubinius we
currently implement the core classes such as Array and Hash in plain
vanilla Ruby. It might be helpful here.)

I still hold out hope for a sufficient degree of type inference
to avoid this, though.

> When I call #some_method, param1 *doesn't* have to be a String or a
> descendant of a String, it just has to be sufficiently String-like
> (which may simply involve defining #to_str).

Right. In Ruby, the type annotation would usually rather be
`#to_str` or `#write` than a type name. My documentation often
states something like "takes a #to_str argument to be used..."

>                                              If you start doing this,
> then you're going to have people who want overloading (see below for the
> reason):
> 
>    def some_method(String param1) => Fixnum; end
>    def some_method(Array param1) => Fixnum; end

I think this is an entirely unwarranted concern.

Either way, and I realise I have contributed to the problem,
I think we should keep further typing discussion out of the
documentation thread to focus on that issue?


Eero

--
Magic is insufficiently advanced technology.