Pepperable

interface Pepperable

Provides a method to convert in PepperVars.

Inheritance

dep_class_pnacl-__PepperableObjectObjectPepperablePepperablePepperable->ObjectIntIntInt->PepperableFloatFloatFloat->PepperableBoolBoolBool->PepperableStringStringString->PepperableFlatStringFlatStringFlatString->String

Parents

  • Object: The root of the class hierarchy.

Children

  • Bool: Native Booleans.
  • Float: Native floating point numbers.
  • Int: Native integer numbers.
  • String: Immutable sequence of characters.

Descendants

Constructors

Concerns

  • pnacl: Provides PNaCl support for Nit.
    • pnacl: Provides PNaCl support for Nit.

in pnacl::pnacl

redef type SELF

Type of this instance, automatically specialized in every class

A common use case of the virtual type SELF is to type an attribute and store another instance of the same type as self. It can also be used as as return type to a method producing a copy of self or returning an instance expected to be the exact same type as self.

This virtual type must be used with caution as it can hinder specialization. In fact, it imposes strict restrictions on all sub-classes and their usage. For example, using SELF as a return type of a method foo forces all subclasses to ensure that foo returns the correct and updated type. A dangerous usage take the form of a method typed by SELF which creates and returns a new instance. If not correctly specialized, this method would break when invoked on a sub-class.

A general rule for safe usage of SELF is to ensure that inputs typed SELF are stored in attributes typed SELF and returned by methods typed SELF, pretty much the same things as you would do with parameter types.