Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Learning Objectives

Note: inspired by and often copied verbatim from (Classic) Lesson: Pico State the original second lesson.

After completing this lesson, you will be able to do the following:

...

Learning Objectives

Note: inspired by and often copied verbatim from (Classic) Lesson: Pico State the original second lesson.

After completing this lesson, you will be able to do the following:

  • Explain what entity variables are.
  • Use rules to mutate entity variables.
  • Use functions to simplify usage of entity variables.
  • Use entity variables to create persistent picos.

Motivation

It is hard to imagine an application these days which doesn't require some form of state. Now remember, a pico is meant to be a digital representation of some physical thing (like a sensor) or a concept (like a collection of sensors). In order to accurately represent either thing, a pico needs to remember and store persistent data. This could be as simple as a boolean on/off if the pico represents a light switch. Or the state could be far more complex. 

The purpose of this lesson is to teach you how to store persistent data in picos. We will refer to persistent data as "entity variables," and you can recognize these variables with the prefix "ent:". The definition of entity according to Google is "a thing with distinct and independent existence." This accurately describes the purpose of entity variables, and I hope this gives you insight into the shortened prefix which denotes them.

Because KRL is a functional language, modifying a persistent variable is restricted to the postlude.

Prerequisites

You should have completed the following lessons:

...