Types and Features for Object Oriented Programming

Construct message-passing style objects with types and features. Q7 types uses composition instead of inheritance in creating derived types, allowing defining any code segment as feature and associating any feature to any object. Compared to R6, Q7 is simpler and more flexible, and is more friendly in syntax.


Q7

Lifecycle:experimental Travis buildstatus

Q7 is a type system that enables a postmodern flavor of compositional object-oriented programming (OOP). It is simple, flexible and promotes healthy program design.

Q7 features:

  • type(), feature() and implement() to compose objects;
  • For each object, initialize() and finalize() to run at its beginning and end of life;
  • For each object, public, private, final, private_final and active binding modifiers to change the visibility and behavior of its members.

Installation

# install.packages("devtools")
devtools::install_github("iqis/Q7")
require(Q7)
#> Loading required package: Q7
#> Loading required package: magrittr
#> 
#> Attaching package: 'Q7'
#> The following object is masked from 'package:base':
#> 
#>     merge

Example

Make a Q7 object in 3 easy steps.

1, Define an object type:

Adder <- type(function(num1, num2){
    add_nums <- function(){
        num1 + num2
    }
 })

2, Instantiate the object:

myAdder <- Adder(1, 2)

3, Enjoy!

myAdder$add_nums()
#> [1] 3

See vignettes for extending an object and other topics.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("Q7")

0.1.0 by Siqi Zhang, 6 years ago


Browse source code at https://github.com/cran/Q7


Authors: Siqi Zhang [aut, cre] , Bayer HealthCare [fnd]


Documentation:   PDF Manual  


GPL-3 license


Depends on magrittr

Suggests knitr, rmarkdown, testthat


See at CRAN