Skip to content

Commit ca38838

Browse files
committed
Merge branches 'meta-data-mixin' and 'mariari/present-init'
3 parents a4f7fc1 + 324ee47 + 49fff07 commit ca38838

File tree

7 files changed

+340
-15
lines changed

7 files changed

+340
-15
lines changed

README

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ Welcome to the GEB project.
55

66
## Links
77

8+
9+
810
Here is the [official repository](https://github.com/anoma/geb/)
911

1012
and [HTML documentation](https://anoma.github.io/geb/) for the latest version.
1113

14+
15+
1216
### code coverage
1317

18+
19+
1420
For test coverage it can be found at the following links:
1521

1622
[SBCL test coverage](./tests/cover-index.html)
@@ -28,6 +34,8 @@ I recommend reading the CCL code coverage version, as it has proper tags.
2834

2935
Currently they are manually generated, and thus for a more accurate assessment see GEB-TEST:CODE-COVERAGE
3036

37+
38+
3139
## Getting Started
3240

3341
Welcome to the GEB Project!
@@ -276,6 +284,8 @@ conjectures about GEB
276284

277285
## Categorical Model
278286

287+
288+
279289
Geb is organizing programming language concepts (and entities!) using
280290
[category theory](https://plato.stanford.edu/entries/category-theory/),
281291
originally developed by mathematicians,
@@ -343,31 +353,31 @@ In particular,
343353
we shall rely on the following
344354
universal constructions:
345355

346-
1. The construction of binary products $A × B$ of sets $A,B$, and the empty product $\mathsf{1}$.
356+
1. The construction of binary products $A × B$ of sets $A,B$, and the empty product $mathsf{1}$.
347357

348358
2. The construction of “function spaces” $B^A$ of sets $A,B$, called *exponentials*,
349359
i.e., collections of functions between pairs of sets.
350360

351361
3. The so-called [*currying*](https://en.wikipedia.org/wiki/Currying)
352362
of functions,
353-
$C^{(B^A)} \cong C^{(A × B)}$,
363+
$C^{(B^A)} cong C^{(A × B)}$,
354364
such that providing several arguments to a function can done
355365
either simultaneously, or in sequence.
356366

357367
4. The construction of sums (a.k.a. co-products) $A + B$ of sets $A,B$,
358368
corresponding to forming disjoint unions of sets;
359-
the empty sum is $\varnothing$.
369+
the empty sum is $varnothing$.
360370

361371
Product, sums and exponentials
362372
are the (almost) complete tool chest for writing
363373
polynomial expressions, e.g.,
364-
$$Ax^{\sf 2} +x^{\sf 1} - Dx^{\sf 0}.$$
374+
$$Ax^{sf 2} +x^{sf 1} - Dx^{sf 0}.$$
365375
(We need these later to define [“algebraic data types”](https://en.wikipedia.org/wiki/Polynomial_functor_(type_theory)).)
366376
In the above expression,
367377
we have sets instead of numbers/constants
368-
where $ \mathsf{2} = \lbrace 1, 2 \rbrace$,
369-
$ \mathsf{1} = \lbrace 1 \rbrace$,
370-
$ \mathsf{0} = \lbrace \rbrace = \varnothing$,
378+
where $ mathsf{2} = lbrace 1, 2 rbrace$,
379+
$ mathsf{1} = lbrace 1 rbrace$,
380+
$ mathsf{0} = lbrace rbrace = varnothing$,
371381
and $A$ and $B$ are arbitrary (finite) sets.
372382
We are only missing a counterpart for the *variable*!
373383
Raising an arbitrary set to “the power” of a constant set
@@ -390,6 +400,8 @@ Benjamin Pierce's
390400
as it is very amenable *and*
391401
covers the background we need in 60 short pages.
392402

403+
404+
393405
### Morphisms
394406

395407

@@ -1744,6 +1756,85 @@ Let's see some example uses of POINTWISE-MIXIN:
17441756
```
17451757

17461758

1759+
### Metadata Mixin
1760+
1761+
Metadata is a form of meta information about a particular
1762+
object. Having metadata about an object may be useful if the goal
1763+
requires annotating some data with type information, identification
1764+
information, or even various levels of compiler information. The
1765+
possibilities are endless and are a standard technique.
1766+
1767+
For this task we offer the META-MIXIN which will allow
1768+
metadata to be stored for any type that uses its service.
1769+
1770+
- [class] META-MIXIN
1771+
1772+
Use my service if you want to have metadata capabilities associated
1773+
with the given object. @MIXIN-PERFORMANCE covers my performance
1774+
characteristics
1775+
1776+
For working with the structure it is best to have operations to treat
1777+
it like an ordinary hashtable
1778+
1779+
- [function] META-INSERT OBJECT KEY VALUE &KEY WEAK
1780+
1781+
Inserts a value into storage. If the key is a one time object, then
1782+
the insertion is considered to be volatile, which can be reclaimed
1783+
when no more references to the data exists.
1784+
1785+
If the data is however a constant like a string, then the insertion is
1786+
considered to be long lived and will always be accessible
1787+
1788+
The :weak keyword specifies if the pointer stored in the value is weak
1789+
1790+
- [function] META-LOOKUP OBJECT KEY
1791+
1792+
Lookups the requested key in the metadata table of the object. We
1793+
look past weak pointers if they exist
1794+
1795+
#### Performance
1796+
1797+
The data stored is at the CLASS level. So having your type take the
1798+
META-MIXIN does interfere with the cache.
1799+
1800+
Due to concerns about meta information being populated over time, the
1801+
table which it is stored with is in a
1802+
[weak](http://www.lispworks.com/documentation/lcl50/aug/aug-141.html)
1803+
hashtable, so if the object that the metadata is about gets
1804+
deallocated, so does the metadata table.
1805+
1806+
The full layout can be observed from this interaction
1807+
1808+
```lisp
1809+
;; any class that uses the service
1810+
(defparameter *x* (make-instance 'meta-mixin))
1811+
1812+
(meta-insert *x* :a 3)
1813+
1814+
(defparameter *y* (make-instance 'meta-mixin))
1815+
1816+
(meta-insert *y* :b 3)
1817+
1818+
(defparameter *z* (make-instance 'meta-mixin))
1819+
1820+
;; where {} is a hashtable
1821+
{*x* {:a 3}
1822+
*y* {:b 3}}
1823+
```
1824+
1825+
Since `*z*` does not interact with storage no overhead of storage is
1826+
had. Further if \`*x* goes out of scope, gc would reclaim the table leaving
1827+
1828+
```lisp
1829+
{*y* {:b 3}}
1830+
```
1831+
1832+
for the hashtable.
1833+
1834+
Even the tables inside each object's map are weak, thus we can make
1835+
storage inside metadata be separated into volatile and stable
1836+
storage.
1837+
17471838
## Geb Utilities
17481839

17491840
###### \[in package GEB.UTILS\]

README.md

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
- [11.1 Pointwise Mixins][d5d3]
5050
- [11.2 Pointwise API][2fcf]
5151
- [11.3 Mixins Examples][4938]
52+
- [11.4 Metadata Mixin][9300]
53+
- [11.4.1 Performance][455b]
5254
- [12 Geb Utilities][4ffa]
5355
- [12.1 Accessors][cc51]
5456
- [13 Testing][9bcb]
@@ -59,13 +61,19 @@ Welcome to the GEB project.
5961
<a id="x-28GEB-DOCS-2FDOCS-3A-40LINKS-20MGL-PAX-3ASECTION-29"></a>
6062
## 1 Links
6163

64+
65+
6266
Here is the [official repository](https://github.com/anoma/geb/)
6367

6468
and [HTML documentation](https://anoma.github.io/geb/) for the latest version.
6569

70+
71+
6672
<a id="x-28GEB-DOCS-2FDOCS-3A-40COVERAGE-20MGL-PAX-3ASECTION-29"></a>
6773
### 1.1 code coverage
6874

75+
76+
6977
For test coverage it can be found at the following links:
7078

7179
[SBCL test coverage](./tests/cover-index.html)
@@ -83,6 +91,8 @@ I recommend reading the CCL code coverage version, as it has proper tags.
8391

8492
Currently they are manually generated, and thus for a more accurate assessment see [`GEB-TEST:CODE-COVERAGE`][417f]
8593

94+
95+
8696
<a id="x-28GEB-DOCS-2FDOCS-3A-40GETTING-STARTED-20MGL-PAX-3ASECTION-29"></a>
8797
## 2 Getting Started
8898

@@ -344,6 +354,8 @@ conjectures about GEB
344354
<a id="x-28GEB-DOCS-2FDOCS-3A-40MODEL-20MGL-PAX-3ASECTION-29"></a>
345355
## 5 Categorical Model
346356

357+
358+
347359
Geb is organizing programming language concepts (and entities!) using
348360
[category theory](https://plato.stanford.edu/entries/category-theory/),
349361
originally developed by mathematicians,
@@ -411,31 +423,31 @@ In particular,
411423
we shall rely on the following
412424
universal constructions:
413425

414-
1. The construction of binary products $A × B$ of sets $A,B$, and the empty product $\mathsf{1}$.
426+
1. The construction of binary products $A × B$ of sets $A,B$, and the empty product $mathsf{1}$.
415427

416428
2. The construction of function spaces $B^A$ of sets $A,B$, called *exponentials*,
417429
i.e., collections of functions between pairs of sets.
418430

419431
3. The so-called [*currying*](https://en.wikipedia.org/wiki/Currying)
420432
of functions,
421-
$C^{(B^A)} \cong C^{(A × B)}$,
433+
$C^{(B^A)} cong C^{(A × B)}$,
422434
such that providing several arguments to a function can done
423435
either simultaneously, or in sequence.
424436

425437
4. The construction of sums (a.k.a. co-products) $A + B$ of sets $A,B$,
426438
corresponding to forming disjoint unions of sets;
427-
the empty sum is $\varnothing$.
439+
the empty sum is $varnothing$.
428440

429441
Product, sums and exponentials
430442
are the (almost) complete tool chest for writing
431443
polynomial expressions, e.g.,
432-
$$Ax^{\sf 2} +x^{\sf 1} - Dx^{\sf 0}.$$
444+
$$Ax^{sf 2} +x^{sf 1} - Dx^{sf 0}.$$
433445
(We need these later to define [algebraic data types](https://en.wikipedia.org/wiki/Polynomial_functor_(type_theory)).)
434446
In the above expression,
435447
we have sets instead of numbers/constants
436-
where $ \mathsf{2} = \lbrace 1, 2 \rbrace$,
437-
$ \mathsf{1} = \lbrace 1 \rbrace$,
438-
$ \mathsf{0} = \lbrace \rbrace = \varnothing$,
448+
where $ mathsf{2} = lbrace 1, 2 rbrace$,
449+
$ mathsf{1} = lbrace 1 rbrace$,
450+
$ mathsf{0} = lbrace rbrace = varnothing$,
439451
and $A$ and $B$ are arbitrary (finite) sets.
440452
We are only missing a counterpart for the *variable*!
441453
Raising an arbitrary set to the power of a constant set
@@ -458,6 +470,8 @@ Benjamin Pierce's
458470
as it is very amenable *and*
459471
covers the background we need in 60 short pages.
460472

473+
474+
461475
<a id="x-28GEB-DOCS-2FDOCS-3A-40MORPHISMS-20MGL-PAX-3ASECTION-29"></a>
462476
### 5.1 Morphisms
463477

@@ -2010,6 +2024,90 @@ Let's see some example uses of [`POINTWISE-MIXIN`][445d]:
20102024
```
20112025

20122026

2027+
<a id="x-28GEB-2EMIXINS-3A-40METADATA-20MGL-PAX-3ASECTION-29"></a>
2028+
### 11.4 Metadata Mixin
2029+
2030+
Metadata is a form of meta information about a particular
2031+
object. Having metadata about an object may be useful if the goal
2032+
requires annotating some data with type information, identification
2033+
information, or even various levels of compiler information. The
2034+
possibilities are endless and are a standard technique.
2035+
2036+
For this task we offer the [`META-MIXIN`][4529] which will allow
2037+
metadata to be stored for any type that uses its service.
2038+
2039+
<a id="x-28GEB-2EMIXINS-3AMETA-MIXIN-20CLASS-29"></a>
2040+
- [class] **META-MIXIN**
2041+
2042+
Use my service if you want to have metadata capabilities associated
2043+
with the given object. [Performance][455b] covers my performance
2044+
characteristics
2045+
2046+
For working with the structure it is best to have operations to treat
2047+
it like an ordinary hashtable
2048+
2049+
<a id="x-28GEB-2EMIXINS-3AMETA-INSERT-20FUNCTION-29"></a>
2050+
- [function] **META-INSERT** *OBJECT KEY VALUE &KEY WEAK*
2051+
2052+
Inserts a value into storage. If the key is a one time object, then
2053+
the insertion is considered to be volatile, which can be reclaimed
2054+
when no more references to the data exists.
2055+
2056+
If the data is however a constant like a string, then the insertion is
2057+
considered to be long lived and will always be accessible
2058+
2059+
The :weak keyword specifies if the pointer stored in the value is weak
2060+
2061+
<a id="x-28GEB-2EMIXINS-3AMETA-LOOKUP-20FUNCTION-29"></a>
2062+
- [function] **META-LOOKUP** *OBJECT KEY*
2063+
2064+
Lookups the requested key in the metadata table of the object. We
2065+
look past weak pointers if they exist
2066+
2067+
<a id="x-28GEB-2EMIXINS-3A-40MIXIN-PERFORMANCE-20MGL-PAX-3ASECTION-29"></a>
2068+
#### 11.4.1 Performance
2069+
2070+
The data stored is at the [`CLASS`][7e58] level. So having your type take the
2071+
[`META-MIXIN`][4529] does interfere with the cache.
2072+
2073+
Due to concerns about meta information being populated over time, the
2074+
table which it is stored with is in a
2075+
[weak](http://www.lispworks.com/documentation/lcl50/aug/aug-141.html)
2076+
hashtable, so if the object that the metadata is about gets
2077+
deallocated, so does the metadata table.
2078+
2079+
The full layout can be observed from this interaction
2080+
2081+
```lisp
2082+
;; any class that uses the service
2083+
(defparameter *x* (make-instance 'meta-mixin))
2084+
2085+
(meta-insert *x* :a 3)
2086+
2087+
(defparameter *y* (make-instance 'meta-mixin))
2088+
2089+
(meta-insert *y* :b 3)
2090+
2091+
(defparameter *z* (make-instance 'meta-mixin))
2092+
2093+
;; where {} is a hashtable
2094+
{*x* {:a 3}
2095+
*y* {:b 3}}
2096+
```
2097+
2098+
Since `*z*` does not interact with storage no overhead of storage is
2099+
had. Further if \`*x* goes out of scope, gc would reclaim the table leaving
2100+
2101+
```lisp
2102+
{*y* {:b 3}}
2103+
```
2104+
2105+
for the hashtable.
2106+
2107+
Even the tables inside each object's map are weak, thus we can make
2108+
storage inside metadata be separated into volatile and stable
2109+
storage.
2110+
20132111
<a id="x-28GEB-2EUTILS-3A-40GEB-UTILS-MANUAL-20MGL-PAX-3ASECTION-29"></a>
20142112
## 12 Geb Utilities
20152113

@@ -2266,6 +2364,8 @@ features and how to better lay out future tests
22662364
[42d7]: http://www.lispworks.com/documentation/HyperSpec/Body/m_defpkg.htm "DEFPACKAGE MGL-PAX:MACRO"
22672365
[43d2]: #x-28GEB-2EMAIN-3ACURRY-20GENERIC-FUNCTION-29 "GEB.MAIN:CURRY GENERIC-FUNCTION"
22682366
[445d]: #x-28GEB-2EMIXINS-3APOINTWISE-MIXIN-20CLASS-29 "GEB.MIXINS:POINTWISE-MIXIN CLASS"
2367+
[4529]: #x-28GEB-2EMIXINS-3AMETA-MIXIN-20CLASS-29 "GEB.MIXINS:META-MIXIN CLASS"
2368+
[455b]: #x-28GEB-2EMIXINS-3A-40MIXIN-PERFORMANCE-20MGL-PAX-3ASECTION-29 "Performance"
22692369
[4850]: http://www.lispworks.com/documentation/HyperSpec/Body/t_kwd.htm "KEYWORD TYPE"
22702370
[4938]: #x-28GEB-2EMIXINS-3A-40MIXIN-EXAMPLES-20MGL-PAX-3ASECTION-29 "Mixins Examples"
22712371
[49d4]: #x-28GEB-2EMAIN-3A-40GEB-UTILITY-20MGL-PAX-3ASECTION-29 "Utility"
@@ -2299,6 +2399,7 @@ features and how to better lay out future tests
22992399
[8fa5]: #x-28GEB-DOCS-2FDOCS-3A-40INSTALLATION-20MGL-PAX-3ASECTION-29 "installation"
23002400
[9162]: #x-28GEB-2EPOLY-2ESPEC-3ACOMPOSE-20TYPE-29 "GEB.POLY.SPEC:COMPOSE TYPE"
23012401
[925b]: #x-28GEB-DOCS-2FDOCS-3A-40POLY-SETS-20MGL-PAX-3ASECTION-29 "Poly in Sets"
2402+
[9300]: #x-28GEB-2EMIXINS-3A-40METADATA-20MGL-PAX-3ASECTION-29 "Metadata Mixin"
23022403
[94a8]: #x-28GEB-2EPOLY-3A-40POLY-MANUAL-20MGL-PAX-3ASECTION-29 "Polynomial Specification"
23032404
[96d0]: http://www.lispworks.com/documentation/HyperSpec/Body/f_equal.htm "EQUAL FUNCTION"
23042405
[97fb]: #x-28GEB-2ESPEC-3A-3CSUBSTMORPH-3E-20TYPE-29 "GEB.SPEC:<SUBSTMORPH> TYPE"

geb.asd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:description "Mixin Utility Functions"
2525
:depends-on (util)
2626
:components ((:file package)
27+
(:file meta)
2728
(:file mixins)))
2829
(:module vampir
2930
:serial t
@@ -104,6 +105,7 @@
104105
:serial t
105106
:components
106107
((:file package)
108+
(:file meta)
107109
(:file geb)
108110
(:file lambda)
109111
(:file lambda-conversion)

0 commit comments

Comments
 (0)