LambLisp 01 Red Fox Alpha
Lisp For Real-Time Control
Loading...
Searching...
No Matches
Lamb Class Reference

Public Types

typedef Sexpr_t(* Mop3st_t) (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec)

Public Member Functions

Sexpr_t load (Charst_t name, Sexpr_t env_exec, Int_t verbosity=0)
Arduino-compatible loop-based control interface.
Sexpr_t setup (void)
Sexpr_t loop (void)
void end (void)
A few foundational functions for embedded debugging.
void log (const char *fmt,...) CHECKPRINTF_pos2
void printf (const char *fmt,...) CHECKPRINTF_pos2
bool debug (void)
void debug (bool onoff)
Information about the current build.
bool build_isDebug ()
unsigned long build_version ()
unsigned long build_UTC ()
unsigned long build_pushUTC ()
const char * build_buildRelease ()
const char * build_buildDate ()
const char * build_pushDate ()
Cell constructors

Garbage collection may happen at any time during the execution of the Cell constructors. The cell constructors that accept S-expression arguments will protect those arguments from GC during the operation, using the gc root push/pop functions.

void expand ()
Sexpr_t tcons (Int_t typ, Word_t a, Word_t b, Sexpr_t env_exec)
Sexpr_t tcons (Int_t typ, Sexpr_t a, Sexpr_t b, Sexpr_t env_exec)
Sexpr_t cons (Sexpr_t a, Sexpr_t b, Sexpr_t env_exec)
Sexpr_t gensym (Sexpr_t env_exec)
void gc_root_push (Sexpr_t p)
void gc_root_pop (Int_t n=1)
A subset of the car/cdr accessors for list cells. This is the subset used within LambLisp.
Sexpr_t car (Sexpr_t l)
Sexpr_t cdr (Sexpr_t l)
Sexpr_t caar (Sexpr_t l)
Sexpr_t cadr (Sexpr_t l)
Sexpr_t cdar (Sexpr_t l)
Sexpr_t cddr (Sexpr_t l)
Sexpr_t caddr (Sexpr_t l)
Sexpr_t cdddr (Sexpr_t l)
Sexpr_t cadddr (Sexpr_t l)
Sexpr_t cddddr (Sexpr_t l)
The "bang" functions are the "mutators" of GC literature.
void set_car_bang (Sexpr_t c, Sexpr_t val)
void set_cdr_bang (Sexpr_t c, Sexpr_t val)
void vector_set_bang (Sexpr_t vec, Int_t k, Sexpr_t val)
Sexpr_t reverse_bang (Sexpr_t l)
Equivalence tests and sequential search
Sexpr_t eq_q (Sexpr_t obj1, Sexpr_t obj2)
Sexpr_t eqv_q (Sexpr_t obj1, Sexpr_t obj2)
Sexpr_t equal_q (Sexpr_t obj1, Sexpr_t obj2)
Sexpr_t assq (Sexpr_t obj, Sexpr_t alist)
Interned symbols

There are just a few operations on symbols:

  • Remember a new symbol.

  • Check if symbol has already been seen.

  • Compare 2 symbols for equality.

  • At evaluation time, lookup the symbol in the current environment.

For best performance, symbols in LambLisp are interned. This means a single copy of the symbol's characters are stored in a data structure containing the set of all interned symbols. Once interned, symbols can be tested for equality by address rather than character-by-character.

Traditionally, the data structure was called oblist if an association list was used, or called obarray if an array was used. Arrays allow for a hash table implementation, which greatly reduces search time, and can be further optimized if the array size is a power of 2 (2^n).

LambLisp uses the term oblist for the interned symbol table, implemented using a 2^n hash table. Symbol hashes are computed only once and are stored with the symbol, speeding runtime lookups.

Sexpr_t oblist_query (Sexpr_t oblist, const char *identifier, Bool_t force, Sexpr_t env_exec)
Sexpr_t oblist_test (Sexpr_t oblist, const char *identifier, Sexpr_t env_exec)
Sexpr_t oblist_intern (Sexpr_t oblist, const char *identifier, Sexpr_t env_exec)
Sexpr_t oblist_analyze (Sexpr_t oblist, Int_t verbosity, Sexpr_t env_exec)
Hierarchical Dictionary type

LambLisp's high-performance hierarchical dictionary implementation is used internally to represent the runtime environment. Dictionaries are also directly usable in the Lisp applications, and the dictionary data type is the basis for the LambLisp Object System (LOBS).

Sexpr_t dict_new (Int_t framesize, Sexpr_t env_exec)
Sexpr_t dict_new (Sexpr_t env_exec)
Sexpr_t dict_add_empty_frame (Sexpr_t dict, Int_t framesize, Sexpr_t env_exec)
Sexpr_t dict_add_empty_frame (Sexpr_t dict, Sexpr_t env_exec)
Sexpr_t dict_add_keyval_frame (Sexpr_t dict, Sexpr_t keys, Sexpr_t vals, Sexpr_t env_exec)
Sexpr_t dict_add_alist_frame (Sexpr_t dict, Sexpr_t alist, Sexpr_t env_exec)
void dict_bind_bang (Sexpr_t dict, Sexpr_t key, Sexpr_t value, Sexpr_t env_exec)
void dict_rebind_bang (Sexpr_t dict, Sexpr_t key, Sexpr_t value, Sexpr_t env_exec)
void dict_bind_alist_bang (Sexpr_t dict, Sexpr_t alist, Sexpr_t env_exec)
void dict_rebind_alist_bang (Sexpr_t dict, Sexpr_t alist, Sexpr_t env_exec)
Sexpr_t dict_ref_q (Sexpr_t dict, Sexpr_t key)
Sexpr_t dict_ref (Sexpr_t dict, Sexpr_t key)
Sexpr_t dict_keys (Sexpr_t dict, Sexpr_t env_exec)
Sexpr_t dict_values (Sexpr_t dict, Sexpr_t env_exec)
Sexpr_t dict_to_alist (Sexpr_t dict, Sexpr_t env_exec)
Sexpr_t dict_to_2list (Sexpr_t dict, Sexpr_t env_exec)
Sexpr_t alist_to_dict (Sexpr_t alist, Sexpr_t env_exec)
Sexpr_t twolist_to_dict (Sexpr_t twolist, Sexpr_t env_exec)
Sexpr_t dict_analyze (Sexpr_t dict, Int_t verbosity=0)
Reading and writing
Sexpr_t read (LL_Port &src, Sexpr_t env_exec)
Sexpr_t write_or_display (Sexpr_t sexpr, Bool_t do_write)
Sexpr_t write_simple (Sexpr_t sexpr)
String sprintf (Charst_t fmt, Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t printf (Sexpr_t args, LL_Port &outp)
Sexpr_t printf (Sexpr_t args)
Evaluation and function application
Sexpr_t eval (Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t eval_list (Sexpr_t args, Sexpr_t env_exec)
Sexpr_t apply_proc_partial (Sexpr_t proc, Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t map_proc (Sexpr_t proc, Sexpr_t lists, Sexpr_t env_exec)
Querying underlying system features defined by Scheme.
Sexpr_t r5_base_environment ()
Sexpr_t r5_interaction_environment ()
Sexpr_t lamb_oblist ()
Sexpr_t current_input_port ()
Sexpr_t current_output_port ()
Sexpr_t current_error_port ()
Useful list processing used internally by the LambLisp virtual machine.
Sexpr_t append (Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t append2 (Sexpr_t lis, Sexpr_t obj, Sexpr_t env_exec)
Sexpr_t list_copy (Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t list_analyze (Sexpr_t sexpr, Sexpr_t env_exec)
Sexpr_t list_to_vector (Sexpr_t l, Sexpr_t env_exec)
Sexpr_t vector_to_list (Sexpr_t v, Sexpr_t env_exec)
Sexpr_t vector_copy (Sexpr_t from, Sexpr_t env_exec)
Sparse vectors

The sparse vector representation is a sorted association list, in which the car of each pair is the vector index and the cdr is the vector value at that index.

Sexpr_t vector_to_sparsevec (Sexpr_t vec, Sexpr_t skip, Sexpr_t env_exec)
Sexpr_t sparsevec_to_vector (Sexpr_t alist, Sexpr_t fill, Sexpr_t env_exec)
Makers for error types

These functions will sprintf a message into a buffer, and return an error object containing the message. They differ in that one (mk_error) creates a new error object, and the other (mk_syserror) avoids use of the memory manager by reusing the system error singleton.

Sexpr_t mk_error (Sexpr_t env_exec, Sexpr_t irritants, const char *fmt,...) CHECKPRINTF_pos4
Sexpr_t mk_error (Sexpr_t env_exec, const char *fmt,...) CHECKPRINTF_pos3
Sexpr_t mk_syserror (const char *fmt,...) CHECKPRINTF_pos2
Sexpr_t mk_syserror (Sexpr_t irritants, const char *fmt,...) CHECKPRINTF_pos3
Makers for simple compact types with embedded values, without external storage or dependencies

These types all have their values embedded in the Cell. Note that other types may also hold immediate values, but are "less simple" because they are C++ subtypes that are variations on the Lisp-declared types.

Sexpr_t mk_bool (Bool_t b, Sexpr_t env_exec)
Sexpr_t mk_character (Char_t ch, Sexpr_t env_exec)
Sexpr_t mk_integer (Int_t i, Sexpr_t env_exec)
Sexpr_t mk_real (Real_t r, Sexpr_t env_exec)
Sexpr_t mk_number (Charst_t str, Sexpr_t env_exec)
Sexpr_t mk_sharp_const (Charst_t name, Sexpr_t env_exec)
Makers for heap storage types

In principle, these types require space from the system heap. At GC time, they may also require specialized marking, and also specialized sweeping.

As an optimization, LambLisp also implements immediate types. When the size required for the object is small, the internal bytes of the Cell can be used to hold the contents, avoiding heap operations. Using immediate types in this way has been common practice for integers and real numbers. LambLisp makes some additional use of immediate types. Immediate types are a LambLisp internal optimization, and they are all subtypes of the main Lisp type.

The types that employ the immediate optimization are:

  • strings, providing up to 9 content bytes plus trailing 0 (32 bit word) or 22 content bytes (64 bit).

  • bytevectors a count plus up to 9 or 22 content bytes.

  • vectors of length 0, 1 or 2.

There are also EXTERNAL versions of those data types. These data types can be used to accesss data that should not be garbage collected, such as data contained in the application image, or C++ objects provided by another application.

A variant of the EXTERNAL types is also provided, so that objects created in C++ can be passed to LambLisp, along with an optional deleter function. In C++, the deleter is best implemented as a one-line C++ lambda function accepting 1 argument (a void* pointer to a C++ object). The deleter function casts the void* pointer to match the C++ object type, and applies the C++ delete or delete[] operators to free the object space and any dependent resources.

By passing the C++ objects to LambLisp, they can be automatically garbage collected when LambLisp has finished with them.

Sexpr_t mk_string (Sexpr_t env_exec, const char *fmt,...) CHECKPRINTF_pos3
Sexpr_t mk_string (Int_t k, Charst_t src, Sexpr_t env_exec)
Sexpr_t mk_string (String s, Sexpr_t env_exec)
Sexpr_t mk_symbol_or_number (Charst_t str, Sexpr_t env_exec)
Sexpr_t mk_symbol (Charst_t str, Sexpr_t env_exec)
Sexpr_t mk_bytevector (Int_t k, Sexpr_t env_exec)
Sexpr_t mk_bytevector (Int_t k, Bytest_t src, Sexpr_t env_exec)
Sexpr_t mk_bytevector (Int_t k, Int_t fill, Sexpr_t env_exec)
Sexpr_t mk_bytevector_ext (Int_t k, Bytest_t ext, Sexpr_t env_exec)
Sexpr_t mk_intvector (Int_t k, Sexpr_t env_exec)
Sexpr_t mk_realvector (Int_t k, Sexpr_t env_exec)
Sexpr_t mk_intvector (Int_t k, Int_t fill, Sexpr_t env_exec)
Sexpr_t mk_realvector (Int_t k, Real_t fill, Sexpr_t env_exec)
Sexpr_t mk_vector (Int_t len, Sexpr_t fill, Sexpr_t env_exec)
Sexpr_t mk_hashtbl (Int_t len, Sexpr_t fill, Sexpr_t env_exec)
Sexpr_t mk_serial_port (Sexpr_t env_exec)
Sexpr_t mk_input_file_port (Charst_t name, Sexpr_t env_exec)
Sexpr_t mk_output_file_port (Charst_t name, Sexpr_t env_exec)
Sexpr_t mk_input_string_port (Charst_t inp, Sexpr_t env_exec)
Sexpr_t mk_output_string_port (Sexpr_t env_exec)
Makers for interface to native procedures and C++ objects.
Sexpr_t mk_Mop3_procst_t (Mop3st_t f, Sexpr_t env_exec)
Sexpr_t mk_Mop3_nprocst_t (Mop3st_t f, Sexpr_t env_exec)
Sexpr_t mk_cppobj (void *obj, CPPDeleterPtr deleter, Sexpr_t env_exec)
Makers for pair types.

These pair types all have the same structure for construction and garbage collection purposes, but are not Scheme pair types. LambLisp*'s scalable type system presents opportunities for efficiency when implementing common operations on lists. These are executed by the LambLisp virtual machine at C++ speed, rather than at the slower speed of the Lisp evaluation loop.

  • procedures ... the evaluator must be able to identify these directly.

  • dictionaries ... often containing cycles when used as environments, so a depth limit is imposed when traversing.

  • thunks ... used in combination with the trampoline technique to implement tail recursion.

Note that there is no need for mk_pair(), it is just cons().

Sexpr_t mk_macro (Sexpr_t nlam, Sexpr_t env_nlam, Sexpr_t env_exec)
Sexpr_t mk_procedure (Sexpr_t formals, Sexpr_t body, Sexpr_t env_proc, Sexpr_t env_exec)
Sexpr_t mk_nprocedure (Sexpr_t formals, Sexpr_t body, Sexpr_t env_nproc, Sexpr_t env_exec)
Sexpr_t mk_thunk_sexpr (Sexpr_t sexpr, Sexpr_t env_thunk, Sexpr_t env_exec)
Sexpr_t mk_thunk_body (Sexpr_t body, Sexpr_t env_thunk, Sexpr_t env_exec)
Sexpr_t mk_dict (Sexpr_t frame, Sexpr_t base, Sexpr_t env_exec)
Sexpr_t mk_dict (Int_t framesize, Sexpr_t env_exec)

Macro support

These macro primitives behave as described in Steele's Common Lisp.

Sexpr_t macroexpand (Sexpr_t form, Sexpr_t env_exec)
Sexpr_t macroexpand1 (Sexpr_t form, Sexpr_t env_exec)
Sexpr_t macroexpand (Sexpr_t proc, Sexpr_t args, Sexpr_t env_exec)
Sexpr_t macroexpand1 (Sexpr_t proc, Sexpr_t args, Sexpr_t env_exec)

Detailed Description

The Lamb class represents a single Lisp virtual machine. To closely match the Arduino-style of loop-based control, LambLisp provides begin(), loop(), and end().

To initialize the LambLisp VM, begin() should be called once before any other call. Generally LambLisp loop() will be called one time for every main loop(), but it is not necessary. If end() is called, all LambLisp resources are freed; Lamb::setup() can be called again to restart that LambLisp VM.

The LambLisp VM functions are grouped this way:

  • Logging functions

  • Build and version informational functions.

  • Cell constructors, getters & setters

  • Base data structures for the interpreter: alist, hash tables, and environments, along with their getters & setters.

  • Printers

  • Partial evaluation and application

  • Port access from Lisp

  • Vector, list, and dictionary utilities, used internally and also available in Lisp.

  • GC interface functions to protect critical sections.

  • Bindings

  • Makers

Member Typedef Documentation

◆ Mop3st_t

typedef Sexpr_t(* Lamb::Mop3st_t) (Lamb &lamb, Sexpr_t sexpr, Sexpr_t env_exec)

This is a pointer to a C++ native function that interacts directly with the S-expression in the given environment. Every LambLisp native function shares this signature. New external functions that conform to this signature can be used from within LambLisp and will run at full speed.

Member Function Documentation

◆ setup()

Sexpr_t Lamb::setup ( void )

Run once after base platform has started. In particular, Serial should be initialized before calling setup().

◆ loop()

Sexpr_t Lamb::loop ( void )

Run often to maintain control. The main responsibility of C++ Lamb::loop() is to call the LambLisp function of the same name (loop).

◆ end()

void Lamb::end ( void )

Release resources used by the Lamb virtual machine.

◆ log()

void Lamb::log ( const char * fmt,
... )

C-level printf feature with a limit on the length of strings produced. Takes care of log prompt.

◆ printf()

void Lamb::printf ( const char * fmt,
... )

C-level printf feature with a limit on the length of strings produced.

◆ debug() [1/2]

bool Lamb::debug ( void )

Return the state of the Lamb internal debug flag.

◆ debug() [2/2]

void Lamb::debug ( bool onoff)

Set the state of the Lamb debug flag.

◆ build_isDebug()

bool Lamb::build_isDebug ( )

Return true if this build is not checked in. This is unrelated to the runtime debug flag.

◆ build_version()

unsigned long Lamb::build_version ( )

Return the build version as a long integer (implemented as a UTC time stamp).

◆ build_UTC()

unsigned long Lamb::build_UTC ( )

Return the UTC time of this build.

◆ build_pushUTC()

unsigned long Lamb::build_pushUTC ( )

Return the UTC time this repo was last pushed.

◆ build_buildRelease()

const char * Lamb::build_buildRelease ( )

Return a pointer to a character array containing the release description.

◆ build_buildDate()

const char * Lamb::build_buildDate ( )

Return a pointer to a character array containing the build date.

◆ build_pushDate()

const char * Lamb::build_pushDate ( )

Return a pointer to a character array containing the date this repo was last pushed.

◆ expand()

void Lamb::expand ( )

Add another block of cells to the population.

◆ tcons() [1/2]

Sexpr_t Lamb::tcons ( Int_t typ,
Word_t a,
Word_t b,
Sexpr_t env_exec )

Generic cell constructor with no GC protection for its arguments.

◆ tcons() [2/2]

Sexpr_t Lamb::tcons ( Int_t typ,
Sexpr_t a,
Sexpr_t b,
Sexpr_t env_exec )

Constructor for any pair type; protects both S-expression arguments.

◆ cons()

Sexpr_t Lamb::cons ( Sexpr_t a,
Sexpr_t b,
Sexpr_t env_exec )
inline

Cell constructor for normal pairs.

◆ gensym()

Sexpr_t Lamb::gensym ( Sexpr_t env_exec)

Produce a new unique symbol.

◆ gc_root_push()

void Lamb::gc_root_push ( Sexpr_t p)

Preserve the cell given from GC, until popped.

◆ gc_root_pop()

void Lamb::gc_root_pop ( Int_t n = 1)

Release the preserved cells for normal GC processing.

◆ set_car_bang()

void Lamb::set_car_bang ( Sexpr_t c,
Sexpr_t val )

Replace the car field in the cell with val. GC flags will be maintained as required.

◆ set_cdr_bang()

void Lamb::set_cdr_bang ( Sexpr_t c,
Sexpr_t val )

Replace the cdr field in the cell with val. GC flags will be maintained as required.

◆ vector_set_bang()

void Lamb::vector_set_bang ( Sexpr_t vec,
Int_t k,
Sexpr_t val )

Replace the specified vector element with val. GC flags will be maintained as required.

◆ reverse_bang()

Sexpr_t Lamb::reverse_bang ( Sexpr_t l)

Reverse the list in-place and return the new list head (the former list tail).

◆ eq_q()

Sexpr_t Lamb::eq_q ( Sexpr_t obj1,
Sexpr_t obj2 )

Return true if 2 cells are the same cell, or are atoms with the same value.

◆ eqv_q()

Sexpr_t Lamb::eqv_q ( Sexpr_t obj1,
Sexpr_t obj2 )

Return true if 1 cells are the same cell, or are atoms with the same value.

◆ equal_q()

Sexpr_t Lamb::equal_q ( Sexpr_t obj1,
Sexpr_t obj2 )

Returns true when obj1 and obj2 are eqv?, and also all their descendants.

◆ assq()

Sexpr_t Lamb::assq ( Sexpr_t obj,
Sexpr_t alist )

Search an association list for a matching key, and return the (key . value) pair, or false if not found.

◆ dict_new() [1/2]

Sexpr_t Lamb::dict_new ( Int_t framesize,
Sexpr_t env_exec )
inline

Return a new empty dictionary with the given top frame size.

◆ dict_new() [2/2]

Sexpr_t Lamb::dict_new ( Sexpr_t env_exec)
inline

Return a new empty dictionary with alist top frame.

◆ dict_add_empty_frame()

Sexpr_t Lamb::dict_add_empty_frame ( Sexpr_t dict,
Sexpr_t env_exec )
inline

Returns a new dictionary with an empty top frame, and an existing dictionary as parent.

◆ dict_add_keyval_frame()

Sexpr_t Lamb::dict_add_keyval_frame ( Sexpr_t dict,
Sexpr_t keys,
Sexpr_t vals,
Sexpr_t env_exec )

Returns a new dictionary with a new top frame containing the keys bound to the values.

◆ dict_add_alist_frame()

Sexpr_t Lamb::dict_add_alist_frame ( Sexpr_t dict,
Sexpr_t alist,
Sexpr_t env_exec )
inline

Returns a new dictionary with the alist bindings added in a new frame on top of the base dictionary.

◆ dict_bind_bang()

void Lamb::dict_bind_bang ( Sexpr_t dict,
Sexpr_t key,
Sexpr_t value,
Sexpr_t env_exec )

Modify the target dictionary; value is re-assigned to keyif found, else created in the top frame.

◆ dict_rebind_bang()

void Lamb::dict_rebind_bang ( Sexpr_t dict,
Sexpr_t key,
Sexpr_t value,
Sexpr_t env_exec )

Modify the target dictionary; value is assigned to key wherever first found in env, else error if not found.

◆ dict_bind_alist_bang()

void Lamb::dict_bind_alist_bang ( Sexpr_t dict,
Sexpr_t alist,
Sexpr_t env_exec )

Modify the target dictionary; binding keys in the alist to their corresponding values.

◆ dict_rebind_alist_bang()

void Lamb::dict_rebind_alist_bang ( Sexpr_t dict,
Sexpr_t alist,
Sexpr_t env_exec )

Modify the target dictionary; rebinding keys in the alist to their corresponding values.

◆ dict_ref_q()

Sexpr_t Lamb::dict_ref_q ( Sexpr_t dict,
Sexpr_t key )

Returns (key value) pair, or false if key is unbound.

◆ dict_ref()

Sexpr_t Lamb::dict_ref ( Sexpr_t dict,
Sexpr_t key )

Returns the value associated with the key in the given dictionary; throws error if key is unbound.

◆ dict_keys()

Sexpr_t Lamb::dict_keys ( Sexpr_t dict,
Sexpr_t env_exec )

Note that keys and values are guaranteed to return in the corresponding order in dict_keys and dict_values, duplicate keys may occur.

Return a list of all the keys in this dictionary. If the dictionary has parents, keys may appear multiple times.

◆ dict_values()

Sexpr_t Lamb::dict_values ( Sexpr_t dict,
Sexpr_t env_exec )

Return a list of all the values in this dictionary. If the dictionary has parents, values may appear multiple times for each key.

◆ dict_to_alist()

Sexpr_t Lamb::dict_to_alist ( Sexpr_t dict,
Sexpr_t env_exec )

Convert the dictionary to an alist, retaining only the top-level (key . value) pairs.

◆ dict_to_2list()

Sexpr_t Lamb::dict_to_2list ( Sexpr_t dict,
Sexpr_t env_exec )

Convert the dictionary to a list of 2-element lists, retaining only the top-level (key value) sublists.

◆ alist_to_dict()

Sexpr_t Lamb::alist_to_dict ( Sexpr_t alist,
Sexpr_t env_exec )

Convert an alist into a dictionary. The resulting dictionary has no parent.

◆ twolist_to_dict()

Sexpr_t Lamb::twolist_to_dict ( Sexpr_t twolist,
Sexpr_t env_exec )

Convert a list of 2-element lists into a dictionary. The resulting dictionary has no parent.

◆ dict_analyze()

Sexpr_t Lamb::dict_analyze ( Sexpr_t dict,
Int_t verbosity = 0 )

Internal integrity check.

◆ eval()

Sexpr_t Lamb::eval ( Sexpr_t sexpr,
Sexpr_t env_exec )

Evaluate the S-expression in the environment provided.

◆ eval_list()

Sexpr_t Lamb::eval_list ( Sexpr_t args,
Sexpr_t env_exec )

Evaluate the list of S-expressions in the environment provided, and return a lkist of results.

◆ apply_proc_partial()

Sexpr_t Lamb::apply_proc_partial ( Sexpr_t proc,
Sexpr_t sexpr,
Sexpr_t env_exec )

Evaluate the function arguments and then apply the function to them. The result may be a tail requiring further evaluation.

◆ map_proc()

Sexpr_t Lamb::map_proc ( Sexpr_t proc,
Sexpr_t lists,
Sexpr_t env_exec )

Apply the procecure to the lists per R5RS.

◆ load()

Sexpr_t Lamb::load ( Charst_t name,
Sexpr_t env_exec,
Int_t verbosity = 0 )

Load and evaluate S-expressions from the named file.

◆ append2()

Sexpr_t Lamb::append2 ( Sexpr_t lis,
Sexpr_t obj,
Sexpr_t env_exec )

Destructively attach obj to the end of lis, which must be a proper list.

◆ list_analyze()

Sexpr_t Lamb::list_analyze ( Sexpr_t sexpr,
Sexpr_t env_exec )

Traverse the list and return either false (if circular), the list length (if a proper list), ###.

◆ mk_error() [1/2]

Sexpr_t Lamb::mk_error ( Sexpr_t env_exec,
Sexpr_t irritants,
const char * fmt,
... )

Fill a new error object with the information given, and return it.

◆ mk_error() [2/2]

Sexpr_t Lamb::mk_error ( Sexpr_t env_exec,
const char * fmt,
... )

Fill a new error object with the information given, and return it. The irritants field is left NIL.

◆ mk_syserror() [1/2]

Sexpr_t Lamb::mk_syserror ( const char * fmt,
... )

Fill the system error object with the info given, and return it.

◆ mk_syserror() [2/2]

Sexpr_t Lamb::mk_syserror ( Sexpr_t irritants,
const char * fmt,
... )

Fill the system error object with the info given, and return it.

◆ mk_bytevector() [1/3]

Sexpr_t Lamb::mk_bytevector ( Int_t k,
Sexpr_t env_exec )

Simplest heap allocation with no initialization.

◆ mk_bytevector() [2/3]

Sexpr_t Lamb::mk_bytevector ( Int_t k,
Bytest_t src,
Sexpr_t env_exec )

Heap allocation with initialization.

◆ mk_bytevector() [3/3]

Sexpr_t Lamb::mk_bytevector ( Int_t k,
Int_t fill,
Sexpr_t env_exec )

Heap allocation with initialization.

◆ mk_bytevector_ext()

Sexpr_t Lamb::mk_bytevector_ext ( Int_t k,
Bytest_t ext,
Sexpr_t env_exec )
inline

Injection of externally allocated memory, which will not be freed at GC time.

◆ mk_intvector()

Sexpr_t Lamb::mk_intvector ( Int_t k,
Sexpr_t env_exec )

Note that integer vectors and real vectors are just bytevectors underneath.

Allocates a bytevector from the heap to ensure proper alignment (no IMM type).

◆ mk_realvector()

Sexpr_t Lamb::mk_realvector ( Int_t k,
Sexpr_t env_exec )

Allocates a bytevector from the heap to ensure proper alignment (no IMM type).