MyNixOS website logo
Description

Prototype Object-Based Programming.

An object oriented system using object-based, also called prototype-based, rather than class-based object oriented ideas.

Proto

Travis-CI Build Status CRAN_Status_Badge Coverage Status

Proto is an R package that facilitates prototype programming, a type of object-oriented programming that does not use classes as an atomic concept (but is powerful enough to encompass them).

The package is lightweight providing a thin layer on top of R environments. Unlike other packages which grow over time proto has become smaller over time as it was successively polished to reduce it to its essentials. Despite its small size prototype-based systems can be more powerful than more complex class-based systems.

Ease of use

The proto package is easy to use because:

  1. few names. There is only one new function name to learn among the core functions. The 'proto' function constructs new proto objects. Remaining core functions include various as.proto methods, assignment and retrieval via $ and is.proto.

  2. documentation. A 15 page report, a reference card, a demo and help files are provided.

  3. consistency. Proto objects form an subclass of the environment class. They are and work like environments.
    One can leverage everything one knows about environments to use proto. The package is highly consistent with R and works the way R works.

  4. concise implementation. The source code, excluding dot.proto, is about one page of code making it possible to rapidly understand it in its entirety not only from the documentation but also by reading its source. (This should not be necessary but its there for those who wish.)

  5. tested. The package has been independently tested by multiple people and has no known bugs. (If you find any please let the developers know!)

Example

The proto package is used like this:

library(proto)

# new object with variable a and method addtwice
oo <- proto(a = 1, addtwice = function(., x) .$a <- .$a + 2*x)

oo$addtwice(3)  # add twice 3 to 1
oo$ls()         # "a" "addtwice"
oo$a            # 7

# create child object overriding a
ooc <- oo$proto(a = 10)

ooc$addtwice(1) # inherit addtwice from parent oo
ooc$ls()        # "a"
ooc$a           # 12 - addtwice from oo used "a" in ooc!

Documentation

More information is available via:

demo(proto)           # a self running demo

vignette("proto")     # 15 page report
vignette("protoref")  # reference card

?proto                # constructs proto objects
?dot.proto            # visualize a proto project
Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows