From: Etienne Vallette d'Osia Date: 2011-11-07T18:53:58+09:00 Subject: [ruby-core:40809] [ruby-trunk - Feature #5583] Optionally typing Issue #5583 has been updated by Etienne Vallette d'Osia. +1 TL;DR I love the idea! I don't know if optional typing is the solution, but the more I use Ruby, the more I miss the robustness that could provide powerful static analysis tools. Moreover, I often read Ruby code, and it is _always_ clearer when types are provided in doc. Why writing types in comments should be better than writing them directly in code? Of course, to be accurate, the typing system should deals with generics (ouch), lambda, non-yet-defined-classes, respond_to types (but these ones could be seen like implicit module! Simpler? Oh wait���) I don't really want to see my favorite language became a Java-like one, but I'm sure it's possible to handle these cases without adding too much complexity, at least with adding complexity on the sides, leaving simple code simple :-) ---------------------------------------- Feature #5583: Optionally typing http://redmine.ruby-lang.org/issues/5583 Author: Yasushi ANDO Status: Open Priority: Normal Assignee: Category: Joke Target version: Although I know all of you dislike static typing it cannot be denied that there are some people aspire for introducing it in ruby. The dartlang solved the problem in unique way called Optionally Typing. In Dart you can declare types for variables but they are ignored by the compiler with default options. It looks superb idea for me so that I introduced the optionally typing to ruby as a trial. You can write types for variables if you want then the ruby completely ignores these dirts. Sample code: def method(arg) arg end def typed_method(arg) : String arg end def fully_typed_method(arg : String) : String arg end var = 'var' puts var var_with_type : String = 'var_with_type' puts var_with_type var_from_method : String = typed_method('var_from_method') puts var_from_method @ivar : String = fully_typed_method('@ivar') puts @ivar Results: $ ./truby -Ilib -I. truby_test.rb var var_with_type var_from_method @ivar I attached my poor patch. Thanks for your consideration. -- http://redmine.ruby-lang.org