orcmid / miser

The Miser Project is practical demonstration of computation-theoretical aspects of software
https://orcmid.github.io/miser/
Apache License 2.0
3 stars 1 forks source link

Define the look-up process for oFrugal binding resolution #61

Open orcmid opened 2 years ago

orcmid commented 2 years ago

There needs to be a function for

  1. Inserting the bound ob for a binding name into a binding data structure (a list)

  2. Checking to see if a binding name has a bound ob and returning that, returning a ?-prefixed lindy when there is no bound ob for that name.

The data structure is passed forward into subsequent oFrugal statements, so that all syntactically-valid oFrugal REPL always have a successful interpretation.

orcmid commented 2 years ago

The basic function is this, there may be different lists, such as one for primitives and one for plain lindies.

The entries in the list are pairs where the b-path is the text of a string and the a-path is the value. The list of entries bottoms out on a singleton, usually NIL.

We draw the lists as [value::string, value::string, ..., value::string] and we assume a string-equality check.

The basic search is

let binding(s, List) 
     = if is-singleton(List)
         then mklindy( prefix("?", s) )
         else if .b .a List = s)
                then .a .a List
                else binding(s, .b List);

the insertion of a binding onto the list is

let update(List, s, ob)
     = (ob :: s) :: List;

there is no removal process. The most-recent for given s is the one that will be found.