Skip to content

Comment on Gradual type checking for Ruby

Comments

I find that putting the method signature at the end of the method definition can become unreadable pretty fast. Also, the fact that it doesn't offer any performance improvement (most probably, this will actually degrade performance) makes me see this as a cool trick, but not really recommended in production.

I like the aproach Perl 6 took on gradual typing. You can read about it in this article which computes fibonnaci's number:http://blogs.perl.org/users/ovid/2015/02/avoid-a-common-soft...

The only reason I wait for the next winter to come is because Perl6 will be production ready by then as Larry Wall announced at FOSDEM this year.

Since Ruby 2.1 (IIRC), method definition returns symbol, therefore it's possible to something like

typesig def meth(arg) arg end, [Numeric] => Numeric

Although it's still end of the method, it already suggests that signature will be there

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.