Optional static typing possible for Ruby?

From http://weblog.infoworld.com/udell/2006/09/06.html:

"We saw a hint of this in episode 2 of The Screening Room, on Adobe
Flex, when Christophe Coenraets talked about the value of ActionScript
3's optional static typing. "When you already know what your types
should be, declare them," he said. "When you don't, don't." One
language, two styles, complementary benefits."

This makes a lot of sense to me. eg a function that processes strings
need not accept anything else, would trap certain errors by declaring
acceptable type(s) and would be easier for code completion in an IDE.

···

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

There's megabytes of discussion on this matter that extend far beyond
the earliest ruby-forum.com presence here. Please search the archives
before bringing this sort of thing up.

Is a StringIO a String object or an IO object? (Hint: it inherits from
neither.) Yet if someone were to put class-based typing (which is
exactly what this is) on a method, they would prevent the use of
StringIO if they wanted IO objects. Further, it is rare that a method
needs *exactly* one type of object unless it's a custom object -- and
even then, it's possible to simulate that a lot of the time.

Type in Ruby is not controlled by classes.

Thank Ghu.

-austin

···

On 9/7/06, Mr Magpie <gazmcgheesubs@yahoo.com.au> wrote:

From http://weblog.infoworld.com/udell/2006/09/06.html:

"We saw a hint of this in episode 2 of The Screening Room, on Adobe
Flex, when Christophe Coenraets talked about the value of ActionScript
3's optional static typing. "When you already know what your types
should be, declare them," he said. "When you don't, don't." One
language, two styles, complementary benefits."

This makes a lot of sense to me. eg a function that processes strings
need not accept anything else, would trap certain errors by declaring
acceptable type(s) and would be easier for code completion in an IDE.

--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
               * austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
               * austin@zieglers.ca

This was pondered as a Ruby 2.0 feature. Haven't seen wind of any concrete ideas yet.

Basically, people can -generally- agree (for given values of every word in this sentence) in the longwinded-threads that some form of contract-checking wouldn't hurt, but that static typing wouldn't work at times. And some alternative forms of contract checking were proposed. And many, many flames were exchanged.

David Vallner