Skip to content
Paul Lipkowski edited this page Aug 22, 2022 · 31 revisions

Entity – a single computable element in PapajScript.

History

The first entities, Number and String, were introduced on April 26, 2018 with the release of the RPN 0.4.0.

Entity types

Current usable entity types:

  • Number, e.g. 5, 2, -10, 20.5 etc.
    More explanation here.
  • String, e.g. "Hello world!", "Shalom!", "h" etc.
    More explanation here.
    See the functions for strings in the String package.
  • Boolean, e.g. TRUE, FALSE
    See the logical functions here.
  • Null, e.g. NULL
  • Function, e.g. fun{ -1 * } etc.
    More explanation here.
  • Exception, e.g. EXC (as of now just basic ones, to be improved)
  • Array, e.g. [], [ 2 1 3 7 ], [ 10 times rand ]
    More explanation here.
    See the functions for arrays in the Array package.
  • LogicalExpression, e.g. ( x 0 > )
    More explanation here.
  • DateTime, e.g. "2005-04-02 21:37:00" Date.toDateTime More explanation here.
    See the functions for arrays in the Date package.

Quasi-types:

  • InstructionBlock, e.g. { x 2 ^ 2 / }

Planned for the future

  • Object
  • File
  • Dataframe

Current unusable data types:

  • Unknown

Removed/replaced types:

  • Expression, e.g. ( x 0 > ) – replaced by LogicalExpression in September 2020

Type casting

Syntax: X command

Programme Operand Purpose
toString convert to a string
toNumber convert to a number
toBoolean convert to a logical value true or false
toArray build an array from N elements of the stack
toException build an exception (if X is a string, then it creates an unraised exception with this string message)
Date.toDateTime builds a datetime either from a string or a real number (assuming it represents Unix epoch time)
raiseException same as above, but it raises exception too

Type checking

Syntax: X command

  • type returns a string containing entity type, e.g. "String"
  • isNumber, isBoolean, isString, isArray, isNull, isException, isLogicalExpression, isFunction, isDateTime – return TRUE or FALSE relatively if an entity is of a type mentioned in the function
Clone this wiki locally