Added work on making namespaces threadsafe.

This commit is contained in:
Simon Brooke 2026-03-28 11:56:36 +00:00
parent 154cda8da3
commit 1afb1b9fad
38 changed files with 1074 additions and 517 deletions

94
src/c/ops/truth.c Normal file
View file

@ -0,0 +1,94 @@
/**
* ops/truth.c
*
* Post Scarcity Software Environment: nil? true? not.
*
* Functions associated with truthiness.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
/**
* @brief true if `p` points to `nil`, else false.
*
* Note that every node has its own copy of `t` and `nil`, and each instance of
* each is considered equivalent. So we don't check the node when considering
* whether `nil` really is `nil`, or `t` really is `t`.
*
* @param p a pointer
* @return true if `p` points to `nil`.
* @return false otherwise.
*/
bool nilp( struct pso_pointer p) {
return (p.page == 0 && p.offset = 0);
}
/**
* @brief Return `true` if `p` points to `nil`, else `false`.
*
* @param p a pointer
* @return true if `p` points to `nil`;
* @return false otherwise.
*/
bool not( struct pso_pointer p) {
return !nilp( p);
}
/**
* @brief `true` if `p` points to `t`, else `false`.
*
* Note that every node has its own copy of `t` and `nil`, and each instance of
* each is considered equivalent. So we don't check the node when considering
* whether `nil` really is `nil`, or `t` really is `t`.
*
* @param p a pointer
* @return true if `p` points to `t`.
* @return false otherwise.
*/
bool truep( struct pso_pointer p) {
return (p.page == 0 && p.offset = 1);
}
/**
* @brief return `t` if the first argument in this frame is `nil`, else `t`.
*
* @param frame The current stack frame;
* @param frame_pointer A pointer to the current stack frame;
* @param env the evaluation environment.
* @return `t` if the first argument in this frame is `nil`, else `t`
*/
pso_pointer lisp_nilp( struct stack_frame *frame,
struct pso_pointer frame_pointer,
struct pso_pointer env ){
return (nilp(frame->arg[0]) ? t : nil);
}
/**
* @brief return `t` if the first argument in this frame is `t`, else `nil`.
*
* @param frame The current stack frame;
* @param frame_pointer A pointer to the current stack frame;
* @param env the evaluation environment.
* @return `t` if the first argument in this frame is `t`, else `nil`.
*/
pso_pointer lisp_truep( struct stack_frame *frame,
struct pso_pointer frame_pointer,
struct pso_pointer env ){
return (truep(frame->arg[0]) ? t : nil);
}
/**
* @brief return `t` if the first argument in this frame is not `nil`, else
* `t`.
*
* @param frame The current stack frame;
* @param frame_pointer A pointer to the current stack frame;
* @param env the evaluation environment.
* @return `t` if the first argument in this frame is not `nil`, else `t`.
*/
pso_pointer lisp_not( struct stack_frame *frame,
struct pso_pointer frame_pointer,
struct pso_pointer env ){
return (not(frame->arg[0]) ? t : nil);
}