Learn R Programming

Q7

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.

Copy Link

Version

Install

install.packages('Q7')

Monthly Downloads

195

Version

0.1.0

License

GPL-3

Maintainer

Siqi Zhang

Last Published

November 25th, 2020

Functions in Q7 (0.1.0)

clone.Q7instance

Clone an Instance
clone

Clone
feature

Create an Object Feature
extend

Extend a Type upon a (Proto)type
type

Create a Q7 Type
%>%

Pipe operator
list2inst

Build a Q7 Object Instance from a List
is

Is it a Q7 Type, Instance or Feature?
implement

Implement any Feature for an Object
feature_generic

Create a Generic Feature
localize

Make a Localized Copy of a Q7 Type or Instance
merge

Merge all Members of Two Instances