Describe what is meant by "use"

I hit a roadblock trying to understand linear types, because I couldn't figure out what is meant to "use" a variable. I eventually think I figured it out, by reading "Linear types can change the world!", but it was not easy to do so. I think a better description of what "use" means would be very helpful for those unfamiliar with linear types, so I took a stab at it. Hope it helps.
This commit is contained in:
Tim Engler 2020-06-30 19:16:59 +08:00 committed by G. Allais
parent 066b37feb4
commit 14725dac67

View File

@ -72,6 +72,11 @@ Linearity
---------
The ``1`` multiplicity expresses that a variable must be used exactly once.
By "used" we mean either:
* if the variable is a data type or primitive value, it is pattern matched against, ex. by being the subject of a *case* statement, or a function argument that is pattern matched against, etc.,
* if the variable is a function, that function is applied (i.e. ran with an argument)
First, we'll see how this works on some small examples of functions and
data types, then see how it can be used to encode `resource protocols`_.