Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
intern.h
Go to the documentation of this file.
1/*
2 * intern.h
3 *
4 * For now this implements an oblist and shallow binding; local environments can
5 * be consed onto the front of the oblist. Later, this won't do; bindings will happen
6 * in namespaces, which will probably be implemented as hash tables.
7 *
8 * Doctrine is that cons cells are immutable, and life is a lot more simple if they are;
9 * so when a symbol is rebound in the master oblist, what in fact we do is construct
10 * a new oblist without the previous binding but with the new binding. Anything which,
11 * prior to this action, held a pointer to the old oblist (as all current threads'
12 * environments must do) continues to hold a pointer to the old oblist, and consequently
13 * doesn't see the change. This is probably good but does mean you cannot use bindings
14 * on the oblist to signal between threads.
15 *
16 * (c) 2017 Simon Brooke <simon@journeyman.cc>
17 * Licensed under GPL version 2.0, or, at your option, any later version.
18 */
19
20#ifndef __intern_h
21#define __intern_h
22
24
25extern struct cons_pointer oblist;
26
27uint32_t get_hash( struct cons_pointer ptr );
28
29void free_hashmap( struct cons_pointer ptr );
30
31void dump_map( URL_FILE * output, struct cons_pointer pointer );
32
33struct cons_pointer hashmap_get( struct cons_pointer mapp,
34 struct cons_pointer key );
35
36struct cons_pointer hashmap_put( struct cons_pointer mapp,
37 struct cons_pointer key,
38 struct cons_pointer val );
39
40struct cons_pointer hashmap_put_all( struct cons_pointer mapp,
41 struct cons_pointer assoc );
42
43struct cons_pointer hashmap_keys( struct cons_pointer map );
44
45struct cons_pointer make_hashmap( uint32_t n_buckets,
46 struct cons_pointer hash_fn,
47 struct cons_pointer write_acl );
48
49struct cons_pointer c_assoc( struct cons_pointer key,
50 struct cons_pointer store );
51
52struct cons_pointer internedp( struct cons_pointer key,
53 struct cons_pointer environment );
54
55struct cons_pointer hashmap_get( struct cons_pointer mapp,
56 struct cons_pointer key );
57
58struct cons_pointer hashmap_put( struct cons_pointer mapp,
59 struct cons_pointer key,
60 struct cons_pointer val );
61
62struct cons_pointer set( struct cons_pointer key,
63 struct cons_pointer value,
64 struct cons_pointer store );
65
66struct cons_pointer deep_bind( struct cons_pointer key,
67 struct cons_pointer value );
68
69struct cons_pointer intern( struct cons_pointer key,
70 struct cons_pointer environment );
71
72#endif
An indirect pointer to a cons cell.
struct cons_pointer hashmap_get(struct cons_pointer mapp, struct cons_pointer key)
Get a value from a hashmap.
Definition intern.c:220
void dump_map(URL_FILE *output, struct cons_pointer pointer)
Definition hashmap.c:138
struct cons_pointer internedp(struct cons_pointer key, struct cons_pointer environment)
Implementation of interned? in C.
Definition intern.c:281
struct cons_pointer hashmap_put(struct cons_pointer mapp, struct cons_pointer key, struct cons_pointer val)
Store this val as the value of this key in this hashmap mapp.
Definition intern.c:385
void free_hashmap(struct cons_pointer ptr)
Free the hashmap indicated by this pointer.
Definition intern.c:110
struct cons_pointer hashmap_keys(struct cons_pointer map)
return a flat list of all the keys in the hashmap indicated by map.
Definition intern.c:162
struct cons_pointer privileged_symbol_nil
the symbol NIL, which is special!
Definition intern.c:54
struct cons_pointer hashmap_put_all(struct cons_pointer mapp, struct cons_pointer assoc)
Copy all key/value pairs in this association list assoc into this hashmap mapp.
Definition intern.c:183
struct cons_pointer make_hashmap(uint32_t n_buckets, struct cons_pointer hash_fn, struct cons_pointer write_acl)
Make a hashmap with this number of buckets, using this hash_fn.
Definition intern.c:137
uint32_t get_hash(struct cons_pointer ptr)
Get the hash value for the cell indicated by this ptr; currently only implemented for string like thi...
Definition intern.c:81
struct cons_pointer c_assoc(struct cons_pointer key, struct cons_pointer store)
Implementation of assoc in C.
Definition intern.c:327
struct cons_pointer intern(struct cons_pointer key, struct cons_pointer environment)
Ensure that a canonical copy of this key is bound in this environment, and return that canonical copy...
Definition intern.c:478
struct cons_pointer oblist
The global object list/or, to put it differently, the root namespace.
Definition intern.c:48
struct cons_pointer deep_bind(struct cons_pointer key, struct cons_pointer value)
Binds this key to this value in the global oblist.
Definition intern.c:447
struct cons_pointer set(struct cons_pointer key, struct cons_pointer value, struct cons_pointer store)
Return a new key/value store containing all the key/value pairs in this store with this key/value pai...
Definition intern.c:412