optional static typing possible for Ruby ?

M

Mr Magpie

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.
 
A

Austin Ziegler

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.

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
 
D

David Vallner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top