1.1 --- a/docs/wiki/Design Wed Jun 23 01:52:42 2021 +0200
1.2 +++ b/docs/wiki/Design Sun Jun 27 19:29:37 2021 +0200
1.3 @@ -697,3 +697,38 @@
1.4 the appropriate parameter of this nature, but programmers could just write
1.5 functions and methods that employ general sequence and mapping parameters
1.6 explicitly instead.
1.7 +
1.8 +== Library and Built-In Types ==
1.9 +
1.10 +{{{#!table
1.11 +'''Lichen''' || '''Python''' || '''Rationale'''
1.12 +==
1.13 +Integers belong to the `integer` type
1.14 +|| Integers are represented using the `int` type
1.15 +|| The `int` callable cannot be used to construct integer values in Lichen
1.16 +==
1.17 +Strings belong to the `string` or `utf8string` types
1.18 +|| Strings are represented using the `str` or `unicode` types
1.19 +|| Separate `str` and `unicode` functions perform conversion to string types
1.20 +}}}
1.21 +
1.22 +=== Integer Type ===
1.23 +
1.24 +In Python, the `int` callable is largely used to convert other types to
1.25 +integers. However, it is also used to test whether instances are integers, and
1.26 +the callable is, in fact, a form of constructor. Since Lichen only supports
1.27 +the definition of initialisers (`__init__`) and not more exotic callables such
1.28 +as `__new__`, which would permit more control over the construction of
1.29 +instances, it cannot easily provide the necessary functionality to redefine
1.30 +the nature of an instance, at least in the case of integers whose identities
1.31 +are their values, which applies in Lichen because tagged values are used in
1.32 +place of integer instances, and thus the "virtual" instance being initialised
1.33 +would actually need to be exchanged instead of being changed in some way.
1.34 +
1.35 +=== String Types ===
1.36 +
1.37 +Similarly, in Python, the `str` and `unicode` callables both convert and
1.38 +construct new instances as well as acting as types. Although an initialiser
1.39 +could be written to mutate the value retained by such instances in Lichen,
1.40 +this precludes the obvious definition of a `str` function as merely a wrapper
1.41 +around the invocation of the `__str__` method of any given object.