# HG changeset patch # User Paul Boddie # Date 1624814977 -7200 # Node ID 1429afa1fe5008f5833b0ae325872095874c54f9 # Parent d5f80f46d2674e3878f0ef2bd3a1d6dee0df8728 Added some notes about the different type names. diff -r d5f80f46d267 -r 1429afa1fe50 docs/wiki/Design --- a/docs/wiki/Design Wed Jun 23 01:52:42 2021 +0200 +++ b/docs/wiki/Design Sun Jun 27 19:29:37 2021 +0200 @@ -697,3 +697,38 @@ the appropriate parameter of this nature, but programmers could just write functions and methods that employ general sequence and mapping parameters explicitly instead. + +== Library and Built-In Types == + +{{{#!table +'''Lichen''' || '''Python''' || '''Rationale''' +== +Integers belong to the `integer` type +|| Integers are represented using the `int` type +|| The `int` callable cannot be used to construct integer values in Lichen +== +Strings belong to the `string` or `utf8string` types +|| Strings are represented using the `str` or `unicode` types +|| Separate `str` and `unicode` functions perform conversion to string types +}}} + +=== Integer Type === + +In Python, the `int` callable is largely used to convert other types to +integers. However, it is also used to test whether instances are integers, and +the callable is, in fact, a form of constructor. Since Lichen only supports +the definition of initialisers (`__init__`) and not more exotic callables such +as `__new__`, which would permit more control over the construction of +instances, it cannot easily provide the necessary functionality to redefine +the nature of an instance, at least in the case of integers whose identities +are their values, which applies in Lichen because tagged values are used in +place of integer instances, and thus the "virtual" instance being initialised +would actually need to be exchanged instead of being changed in some way. + +=== String Types === + +Similarly, in Python, the `str` and `unicode` callables both convert and +construct new instances as well as acting as types. Although an initialiser +could be written to mutate the value retained by such instances in Lichen, +this precludes the obvious definition of a `str` function as merely a wrapper +around the invocation of the `__str__` method of any given object. diff -r d5f80f46d267 -r 1429afa1fe50 docs/wiki/Representations --- a/docs/wiki/Representations Wed Jun 23 01:52:42 2021 +0200 +++ b/docs/wiki/Representations Sun Jun 27 19:29:37 2021 +0200 @@ -54,12 +54,12 @@ obtaining an instance under normal circumstances, instead provides the address of a common integer instance. This instance may then provide instance attributes, whose values will be the same for all integers, or class -attributes through a reference to the integer (`int`) class. +attributes through a reference to the `integer` class. -Each method provided by `int`, when called, will be given the original +Each method provided by `integer`, when called, will be given the original attribute for which the method was obtained as its context. In such methods, -operations on the context via `self` will either involve the propagation of -the attribute to other functions or methods or attribute accesses on `self`, +operations on the context via `self` will either involve the propagation of the +attribute to other functions or methods or attribute accesses on `self`, yielding common instance attributes or class attributes as already described. Only native functions will attempt to interpret the attribute in a different way, decoding the representation, performing arithmetic or logical operations, diff -r d5f80f46d267 -r 1429afa1fe50 docs/wiki/ToDo --- a/docs/wiki/ToDo Wed Jun 23 01:52:42 2021 +0200 +++ b/docs/wiki/ToDo Sun Jun 27 19:29:37 2021 +0200 @@ -14,14 +14,14 @@ === Numeric Types === -Support all the numeric types. Currently, only `int` is supported, but `float` -merely requires some native code handling operations and testing for exception -conditions. A representation for `long` needs to be determined, and `complex` -probably just needs some methods implementing. +Support all the numeric types. Currently, only `int` is supported (as +`integer`), but `float` merely requires some native code handling operations +and testing for exception conditions. A representation for `long` needs to be +determined, and `complex` probably just needs some methods implementing. -Support promotion between some of the numeric types. Currently, `int` values -that overflow raise `OverflowError`, as was done in Python before automatic -promotion to `long`. +Support promotion between some of the numeric types. Currently, `integer` +values that overflow raise `OverflowError`, as was done in Python before +automatic promotion to `long`. === String Types ===