|
Post Scarcity
A prototype for a post scarcity programming environment
|
#include <math.h>#include <stdbool.h>#include <string.h>#include "arith/integer.h"#include "arith/peano.h"#include "arith/ratio.h"#include "debug.h"#include "memory/conspage.h"#include "memory/consspaceobject.h"#include "memory/vectorspace.h"#include "ops/equal.h"#include "ops/intern.h"Go to the source code of this file.
Functions | |
| bool | end_of_string (struct cons_pointer string) |
| Some strings will be null terminated and some will be NIL terminated... ooops! | |
| bool | eq (struct cons_pointer a, struct cons_pointer b) |
| Shallow, and thus cheap, equality: true if these two objects are the same object, else false. | |
| bool | equal (struct cons_pointer a, struct cons_pointer b) |
| Deep, and thus expensive, equality: true if these two objects have identical structure, else false. | |
| bool | equal_integer_number (struct cons_pointer a, struct cons_pointer b) |
| Private function, don't use. | |
| bool | equal_integer_real (struct cons_pointer a, struct cons_pointer b) |
| Private function, don't use. | |
| bool | equal_ld_ld (long double a, long double b) |
| compare two long doubles and returns true if they are the same to within a tolerance of one part in a billion. | |
| bool | equal_map_map (struct cons_pointer a, struct cons_pointer b) |
| equality of two map-like things. | |
| bool | equal_number_number (struct cons_pointer a, struct cons_pointer b) |
| Private function, don't use. | |
| bool | equal_real_number (struct cons_pointer a, struct cons_pointer b) |
| Private function, don't use. | |
| bool | equal_vector_vector (struct cons_pointer a, struct cons_pointer b) |
| equality of two vector-space things. | |
| bool | same_type (struct cons_pointer a, struct cons_pointer b) |
| True if the objects at these two cons pointers have the same tag, else false. | |
| bool end_of_string | ( | struct cons_pointer | string | ) |
Some strings will be null terminated and some will be NIL terminated... ooops!
| string | the string to test |
Definition at line 51 of file equal.c.
References nilp, cons_space_object::payload, and pointer2cell.
| bool eq | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Shallow, and thus cheap, equality: true if these two objects are the same object, else false.
Definition at line 28 of file equal.c.
References cons_pointer::offset, and cons_pointer::page.
Referenced by equal(), equal_number_number(), equal_vector_vector(), lisp_add(), lisp_eq(), lisp_repl(), make_ratio(), and release_integer().
| bool equal | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Deep, and thus expensive, equality: true if these two objects have identical structure, else false.
Definition at line 332 of file equal.c.
References c_cdr(), CONSTV, DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), eq(), equal(), equal_number_number(), equal_vector_vector(), KEYTV, LAMBDATV, nilp, NLAMBDATV, numberp, cons_space_object::payload, pointer2cell, same_type(), STRING_SHIPYARD_SIZE, STRINGTV, SYMBOLTV, cons_space_object::tag, and VECTORPOINTTV.
Referenced by c_assoc(), equal(), equal_map_map(), internedp(), and lisp_equal().
| bool equal_integer_number | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Private function, don't use.
It depends on its arguments being numbers and doesn't sanity check them.
| a | a lisp integer – if it isn't an integer, things will break. |
| b | a lisp number. |
Definition at line 124 of file equal.c.
References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_integer_integer(), equal_integer_real(), INTEGERTV, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.
Referenced by equal_number_number().
| bool equal_integer_real | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Private function, don't use.
It depends on its arguments being numbers and doesn't sanity check them.
| a | a lisp integer – if it isn't an integer, things will break. |
| b | a lisp real – if it isn't a real, things will break. |
Definition at line 91 of file equal.c.
References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_ld_ld(), nilp, cons_space_object::payload, and pointer2cell.
Referenced by equal_integer_number(), and equal_real_number().
| bool equal_ld_ld | ( | long double | a, |
| long double | b | ||
| ) |
compare two long doubles and returns true if they are the same to within a tolerance of one part in a billion.
| a | |
| b |
a and b are equal to within one part in a billion. Definition at line 65 of file equal.c.
References DEBUG_ARITH, and debug_printf().
Referenced by equal_integer_real(), and equal_real_number().
| bool equal_map_map | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
equality of two map-like things.
The list returned by keys on a map-like thing is not sorted, and is not guaranteed always to come out in the same order. So equality is established if:
a is the same in map a and in map b.Private function, do not use outside this file, WILL NOT work unless both arguments are VECPs.
| a | a pointer to a vector space object. |
| b | another pointer to a vector space object. |
Definition at line 265 of file equal.c.
References c_car(), c_cdr(), c_length(), equal(), hashmap_get(), hashmap_keys(), and nilp.
Referenced by equal_vector_vector().
| bool equal_number_number | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Private function, don't use.
It depends on its arguments being numbers and doesn't sanity check them.
| a | a number |
| b | a number |
Definition at line 199 of file equal.c.
References DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), eq(), equal_integer_number(), equal_ratio_ratio(), equal_real_number(), INTEGERTV, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.
Referenced by equal().
| bool equal_real_number | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
Private function, don't use.
It depends on its arguments being numbers and doesn't sanity check them.
| a | a lisp real – if it isn't an real, things will break. |
| b | a lisp number. |
Definition at line 159 of file equal.c.
References c_ratio_to_ld(), DEBUG_ARITH, debug_print(), debug_print_object(), debug_printf(), equal_integer_real(), equal_ld_ld(), INTEGERTV, cons_space_object::payload, pointer2cell, RATIOTV, REALTV, and cons_space_object::tag.
Referenced by equal_number_number().
| bool equal_vector_vector | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
equality of two vector-space things.
Expensive, but we need to be able to check for equality of at least hashmaps and namespaces.
Private function, do not use outside this file, not guaranteed to work unless both arguments are VECPs pointing to map like things.
| a | a pointer to a vector space object. |
| b | another pointer to a vector space object. |
Definition at line 299 of file equal.c.
References eq(), equal_map_map(), HASHTV, vector_space_object::header, NAMESPACETV, pointer_to_vso, vector_space_header::tag, and vectorp.
Referenced by equal().
| bool same_type | ( | struct cons_pointer | a, |
| struct cons_pointer | b | ||
| ) |
True if the objects at these two cons pointers have the same tag, else false.
| a | a pointer to a cons-space object; |
| b | another pointer to a cons-space object. |
Definition at line 39 of file equal.c.
References pointer2cell, and cons_space_object::tag.
Referenced by equal().