On Thu, 20 May 2004, Sean Russell wrote:

> I'm posting a lot on this topic because I think we have people
> approaching the issue from two different directions.

I like what you are saying, it is an excellent idea. In fact I like it
so much, because it is one of my own, (although we probably came to it
entirely independently).

My pet hobby over the last several years has been to design a postfix,
linear logic combination of Joy and Ruby that does exactly what you
are suggesting.

> Inferrence duck-type checking doesn't constrain the interface
> significantly.
>
> Consider:
>
>   def meth( arg )
>     arg.each { |x| ... }
>   end
>
> Now, the type checker knows that arg *must* implement #each(), and
> that each() should accept a closure, right?  So if call this method
> from somewhere else with:


I immediately see two problems with implementation though...

a) Ruby is too dynamic, the value it is called with may well gain the
   method between compilation and execution of that line. A case in
   point is the 'cgi' module which won't just break under your ruling, it will
   shatter.

b) Ruby has a remarkbly "narrow" (local) view of the world as it
   compiles, to implement your suggest it would require a more global
   view, if not multiple passes. This "local" view is important, it
   keeps Ruby simple and fast.

Perhaps your suggestion should be implemented as a standalone "lint"
rather than as part of Ruby.



John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand

The universe is absolutely plastered with the dashed lines exactly one
space long.