Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
complexvalues [2019/01/04 16:56] christian [Using Values] |
complexvalues [2021/02/05 17:36] christian [Anatomy of a Value] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Complex | + | ===== Values ===== |
The Values package is my base library for almost everything I do. It provides Values (as opposed to Objects) which are simple, immutable objects. Values can only be created but never modified. This allows for a functional programming style and simplyfies systems, since much less state has to be maintained. Especially I like to see all structure and details (of complex values) at a glance and the ease of creating test values. | The Values package is my base library for almost everything I do. It provides Values (as opposed to Objects) which are simple, immutable objects. Values can only be created but never modified. This allows for a functional programming style and simplyfies systems, since much less state has to be maintained. Especially I like to see all structure and details (of complex values) at a glance and the ease of creating test values. | ||
+ | Features: | ||
+ | * Values as known in the functional world: immutable and consisting only of values or primitive types. Values do not have an identity and are equal when their elements are equal. A Value always forms a simple tree without loops or references. Instead of mutating objects, values are copied with new elements. Values are created with a constructor taking all elements as arguments. | ||
+ | * Literal: every value can print itself '' | ||
+ | * Defaults: elements can have a default, so that they can be omited in the constructor. This simplifies systems, since only the relevant data has to be given and the defaults are hidden. | ||
+ | * Named Values: some instances of a value class may be well known and should be use in the code instead of the generic constructor. This feature should be used with caution, since changes will break code using obsolete instances. Currently, only '' | ||
==== Motivation ==== | ==== Motivation ==== | ||
Line 101: | Line 106: | ||
</ | </ | ||
- | Every value class has an # | + | Every value class has an # |
<code smalltalk> | <code smalltalk> |