source: project/wiki/eggref/5/srfi-123 @ 37341

Last change on this file since 37341 was 37341, checked in by dieggsy, 21 months ago

Add Chicken 5 wiki page from srfi-123

File size: 2.7 KB
Line 
1[[tags: egg]]
2
3[[toc:]]
4
5== srfi-123
6
7Generic accessor and modifier operators. For more information, see
8[[http://srfi.schemers.org/srfi-123/srfi-123.html|SRFI-123]].
9
10=== Procedures
11
12<procedure>(ref object field [default])</procedure>
13<procedure>(~ object field [default])</procedure>
14
15Access value in {{object}} specified by {{field}}. If there is no such value,
16signal an error.
17
18{{~}} is the same procedure as {{ref}}.
19
20If {{object}} is a sparse type, meaning its fields can be "empty" or
21"unassigned" (such as a hashtable) and the requested field is empty, the value
22of {{default}} is returned, if that argument is supplied, or an error is
23signaled.
24
25Note that this is an [[http://srfi.schemers.org/srfi-17/srfi-17.html|SRFI-17]]
26{{getter-with-setter}}, so the value specified by {{field}} can be set with:
27
28<enscript highlight=scheme>
29(set! (ref object field) value)
30</enscript>
31
32By default, works on [[srfi-69]] hash-tables, lists/pairs, strings, vectors,
33[[srfi-99]] records, [[srfi-4]] vectors, and [[box]] boxes.
34
35<procedure>(ref* object field ...)</procedure>
36
37Access value specified by one or more {{field}}s in nested {{object}}.
38
39This is also an [[http://srfi.schemers.org/srfi-17/srfi-17.html|SRFI-17]]
40{{getter-with-setter}}.
41
42<procedure>(register-getter-with-setter! type getter sparse?)</procedure>
43
44Registers a new type/getter/setter for use with {{ref}} or {{ref*}}.
45
46
47=== Author
48
49Original implementation by Taylan Ulrich Bayırlı/Kammer, now maintained by
50Diego A. Mundo.
51
52
53=== License
54
55Copyright 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
56
57Copyright 2017 Diego A. Mundo <dieggsy@pm.me>
58
59Permission is hereby granted, free of charge, to any person obtaining a copy of
60this software and associated documentation files (the "Software"), to deal in
61the Software without restriction, including without limitation the rights to
62use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
63of the Software, and to permit persons to whom the Software is furnished to do
64so, subject to the following conditions:
65
66The above copyright notice and this permission notice shall be included in all
67copies or substantial portions of the Software.
68
69THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
75SOFTWARE.
76
77=== Version History
78
79; 0.2.1: Clean up dependencies
80; 0.2 : Port to CHICKEN 5
81; 0.1 : Taken from the srfi-123 core library unit and released as an egg.
Note: See TracBrowser for help on using the repository browser.