The Essence of Ruby
Ruby is a dynamic, object-oriented language with advanced features such as yield operator and dynamic class manipulation. They make Ruby a popular, highly productive scripting language, but they also make the semantics of Ruby complicated and difficult to understand. Even the JIS/ISO standard of Ruby seems to contain some ambiguities. For Ruby to be established as a reliable scripting language, it should have a rigorous semantics. To meet this challenge, we present a formal operational semantics that can serve as a high-level specification for both the users and implementers. The key insight underlying the semantics is that various elaborate features of Ruby can be cleanly represented as a composition of two orthogonal calculi: one for objects and classes and the other for representing control. The presented semantics leads straightforwardly to a reference implementation. Initial evaluation of our implementation confirms that the presented semantics conforms to commonly accepted Ruby behavior.
KeywordsRuby operational semantics iterator dynamic language
Unable to display preview. Download preview PDF.
- 2.An, J.-H., Chaudhuri, A., Foster, J.S.: Static typing for Ruby on Rails. In: IEEE/ACM International Conference on Automated Software Engineering, pp. 590–594 (2009)Google Scholar
- 3.An, J.-H., Chaudhuri, A., Foster, J.S., Hicks, M.: Dynamic inference of static types for Ruby. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 459–472 (2011)Google Scholar
- 4.Furr, M., An, J.-H., Foster, J.S.: Profile-guided static typing for dynamic scripting languages. In: ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, pp. 283–300 (2009)Google Scholar
- 5.Furr, M., An, J.-H., Foster, J.S., Hicks, M.: The Ruby intermediate language. In: Symposium on Dynamic Languages, pp. 89–98 (2009)Google Scholar
- 6.Furr, M., An, J.-H., Foster, J.S., Hicks, M.: Static type inference for Ruby. In: ACM Symposium on Applied Computing, pp. 1859–1866 (2009)Google Scholar
- 8.ISO/IEC 30170:2012, Information technology – Programming languages – Ruby (2012)Google Scholar
- 9.James, R.P., Sabry, A.: Yield: Mainstream delimited continuations. In: Workshop on the Theory and Practice of Delimited Continuations, pp. 20–32 (2011)Google Scholar
- 10.JIS X 3017:2011, Programming languages – Ruby (2011)Google Scholar
- 13.Milner, R., Tofte, M., MacQueen, D.: The Definition of Standard ML. MIT Press (1997)Google Scholar
- 14.Politz, J.G., Martinez, A., Milano, M., Warren, S., Patterson, D., Li, J., Chitipothu, A., Krishnamurthi, S.: Python: the full monty. In: ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages and Applications, pp. 217–232 (2013)Google Scholar
- 15.Ruby programming language, http://www.ruby-lang.org/en/