Alex Rivera | Logout

What prevents a statically typed language from having something like Ruby's method_missing?

Asked 2010-09-24T15:28:11.923
12

I don't have much experience with statically typed languages (currently learning Scala and loving it!) but one thing I've noticed is that they don't ever seem to have anything like Ruby's method_missing or ColdFusion's onMissingMethod. Is there some inherent limitation in statically typed languages that prevent or make this difficult?

Edit
Report

1 Answer

2

Scala version 2.9 introduces this functionality through the Dynamic trait (scaladoc). Classes that extend Dynamic get the magical method applyDynamic(methodName, args), which is analogous to Ruby's method_missing. As of Scala 2.9, the -Xexperimental option must be enabled to use Dynamic.

answered 2011-06-25T19:35:51.583

Your Answer