Abstract
This paper concerns object-oriented embedded DSLs, which are popular in the Ruby community but have received little attention in the research literature. Ruby DSLs implement language keywords as implicit method calls to self; language structure is enforced by adjusting which object is bound to self in different scopes. While Ruby DSLs are powerful and elegant, they suffer from a lack of specification. In this paper, we introduce contracts for Ruby DSLs, which allow us to attribute blame appropriately when there are inconsistencies between an implementation and client. We formalize Ruby DSL contract checking in DSL, a core calculus that uses premethods with instance evaluation to enforce contracts. We then describe RDL, an implementation of Ruby DSL contracts. Finally, we present two tools that automatically infer RDL contracts: TypeInfer infers simple, type-like contracts based on observed method calls, and DSLInfer infers DSL keyword scopes and nesting by generating and testing candidate DSL usages based on initial examples. The type contracts generated by TypeInfer work well enough, though they are limited in precision by the small number of tests, while DSLInfer finds almost all DSL structure. Our goal is to help users understand a DSL from example programs.
- An, J., Chaudhuri, A., Foster, J.S., Hicks, M.: Dynamic Inference of Static Types for Ruby. In: Principles of Programming Languages (POPL). pp. 459--472 (2011) Google Scholar
Digital Library
- Ancona, D., Ancona, M., Cuni, A., Matsakis, N.: RPython: a Step Towards Reconciling Dynamically and Statically Typed OO Languages. In: DLS 2007. pp. 53--64 (2007) Google Scholar
Digital Library
- Anderson, C., Giannini, P., Drossopoulou, S.: Towards Type Inference for JavaScript. In: European Conference on Object-Oriented Programming. LNCS, vol. 3586, pp. 428--452 (2005) Google Scholar
Digital Library
- Austin, T.H., Disney, T., Flanagan, C.: Virtual values for language extension. In: Object-Oriented Programming, Systems, Languages, and Applications. pp. 921--938 (2011) Google Scholar
Digital Library
- Aycock, J.: {Aggressive Type Inference}. In: International Python Conference (2000)Google Scholar
- Bentley, J.: Programming pearls: little languages. Communications of the ACM 29(8), 711--721 (Aug 1986) Google Scholar
Digital Library
- Bhargava, A.: contracts.ruby (2012), https://github.com/egonSchiele/contracts.rubyGoogle Scholar
- Claessen, K., Ljunglof, P.: Typed logical variables in Haskell. In: Proceedings of the 2000 Haskell Workshop (2000)Google Scholar
- Clinger, W., Rees, J.: Macros that work. In: Symposium on Principles of Programming Languages. pp. 155--162 (1991) Google Scholar
Digital Library
- van Deursen, A., Klint, P., Visser, J.: Domain-specific languages: An annotated bibliography. SIGPLAN Not. 35(6), 26--36 (Jun 2000) Google Scholar
Digital Library
- Dybvig, R.K., Hieb, R., Bruggeman, C.: Syntactic abstraction in Scheme. LISP and Symbolic Computation 5(4), 295--326 (1993) Google Scholar
Digital Library
- Elliott, C.: Programming graphics processors functionally. In: Proceedings of the 2004 Haskell Workshop (2004), http://conal.net/papers/Vertigo/ Google Scholar
Digital Library
- Felleisen, M., Friedman, D.P.: Control operators, the SECD-machine, and the ε-calculus. In: Formal Description of Programming Concepts III. pp. 193--217 (1986)Google Scholar
- Findler, R.B., Blume, M.: Contracts as pairs of projections. In: International Conference on Functional and Logic Programming. pp. 226--241 (2006) Google Scholar
Digital Library
- Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: International Conference on Functional Programming. pp. 48--59 (Oct 2002) Google Scholar
Digital Library
- Flatt, M.: Composable and Compilable Macros: You Want it When? In: International Conference on Functional Programming. pp. 72--83 (2002) Google Scholar
Digital Library
- Flatt, M., Culpepper, R., Darais, D., Findler, R.B.: {Macros that Work Together. Journal of Functional Programming 22, 181--216 (2012) Google Scholar
Digital Library
- Flatt, M., PLT: Reference: Racket. Tech. Rep. PLT-TR-2010--1, PLT Inc. (2010), http://racket-lang.org/tr1/Google Scholar
- Furr, M., An, J., Foster, J.S., Hicks, M.: The Ruby Intermediate Langauge. In: Dynamic Languages Symposium (DLS). pp. 89--98. Orlando, Florida (October 2009) Google Scholar
Digital Library
- Guy L. Steele, Jr.: Common LISP: the Language, 2nd Edition. Digital Press, Newton, MA, USA (1990) Google Scholar
Digital Library
- Hudak, P.: Building domain-specific embedded languages. ACM Computing Surveys 28 (1996) Google Scholar
Digital Library
- Hudak, P.: Modular domain specific languages and tools. In: in Proceedings of Fifth International Conference on Software Reuse. pp. 134--142. IEEE Computer Society Press (1998) Google Scholar
Digital Library
- Leijen, D., Meijer, E.: Domain specific embedded compilers. In: Conference on Domain-specific Languages. pp. 109--122 (1999) Google Scholar
Digital Library
- Ousterhout, J.K., Jones, K.: Tcl and the Tk Toolkit, 2nd Edition. Addison-Wesley Professional, Boston, MA, USA (2009) Google Scholar
Digital Library
- Perrotta, P.: Metaprogramming Ruby. Pragmatic Bookshelf (2010) Google Scholar
Digital Library
- Reid, A., Peterson, J., Hager, G., Hudak, P.: Prototyping real-time vision systems: an experiment in dsl design. In: International Conference on Software engineering. pp. 484--493 (1999) Google Scholar
Digital Library
- Ren, B.M., Toman, J., Strickland, T.S., Foster, J.S.: {The {R}uby Type Checker}. In: Symposium on Applied Computing. pp. 1565--1572 (2013) Google Scholar
Digital Library
- Riehl, J.: Language embedding and optimization in Mython. In: Symposium on Dynamic Languages. pp. 39--48. DLS '09 (2009) Google Scholar
Digital Library
- Sperber, M., Dybvig, R.K., Flatt, M., Van Straaten, A., Findler, R., Matthews, J.: Revised6 Report on the Algorithmic Language Scheme. Journal of Functional Programming 19, 1--301 (2009) Google Scholar
Digital Library
- Strickland, T.S., Felleisen, M.: Contracts for first-class classes. In: Symposium on Dynamic Languages. pp. 97--111 (Oct 2010) Google Scholar
Digital Library
- Strickland, T.S., Tobin-Hochstadt, S., Findler, R.B., Flatt, M.: Chaperones and Impersonators: Run-time Support for Reasonable Interposition. In: Object-Oriented Programming, Systems, Languages, and Applications. pp. 943--962 (2012) Google Scholar
Digital Library
- Team, R.C.: R Language Definition. http://cran.r-project.org/doc/manuals/r-release/R-lang.htmlGoogle Scholar
- Thiemann, P.: Modeling HTML in Haskell. In: International Workshop on Practical Aspects of Declarative Languages. pp. 263--277 (2000) Google Scholar
Digital Library
- Thiemann, P.: Towards a Type System for Analyzing JavaScript. In: European Symposium on Programming. LNCS, vol. 3444, pp. 408--422 (2005) Google Scholar
Digital Library
- Wickham, H.: Advanced R programming (Nov 2013), http://adv-r.had.co.nz/dsl.htmlGoogle Scholar
Index Terms
Contracts for domain-specific languages in Ruby
Recommendations
Contracts for domain-specific languages in Ruby
DLS '14: Proceedings of the 10th ACM Symposium on Dynamic languagesThis paper concerns object-oriented embedded DSLs, which are popular in the Ruby community but have received little attention in the research literature. Ruby DSLs implement language keywords as implicit method calls to self; language structure is ...
Development of internal domain-specific languages: design principles and design patterns
PLoP '11: Proceedings of the 18th Conference on Pattern Languages of ProgramsA great part of software development challenges can be solved by one universal tool: Abstraction. Developers solve development challenges by using expressions and concepts that abstract from too technical details. One especially supportive tool for ...
A domain-specific language for building self-optimizing AST interpreters
GPCE '14Self-optimizing AST interpreters dynamically adapt to the provided input for faster execution. This adaptation includes initial tests of the input, changes to AST nodes, and insertion of guards that ensure assumptions still hold. Such specialization ...







Comments