From cffecb57f88acb02354b68a9ffe22abbabd5931d Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Wed, 12 Mar 2014 16:17:01 -0400 Subject: basic docs --- README | 9 +++++++++ howto.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 README create mode 100644 howto.txt diff --git a/README b/README new file mode 100644 index 0000000..487f96b --- /dev/null +++ b/README @@ -0,0 +1,9 @@ + _ + ___ _ __ ___ ___| |_ _ __ _ _ _ __ ___ + / __| '_ \ / _ \/ __| __| '__| | | | '_ ` _ \ + \__ \ |_) | __/ (__| |_| | | |_| | | | | | | + |___/ .__/ \___|\___|\__|_| \__,_|_| |_| |_| + |_| + + a set of lambdas + diff --git a/howto.txt b/howto.txt new file mode 100644 index 0000000..1a29af2 --- /dev/null +++ b/howto.txt @@ -0,0 +1,51 @@ + +### How to implement a simple scheme? + +Potentially need an AST-like data structure representing the parsed expression. +This is the s-expression. Well represented as a pair with value types: + + null + pair + boolean (true/false) + number + identifier/symbol + +One way to accomplish the above would be to use a pair datatype in the host +language. Another is to try to use tuples or lists; this will result in faster +execution but is much harder? + +'value' and other high level functions will take an s-expr and return an +s-expr. eval wraps this with an AST parse at the begining and a pretty print at +the end. + +'meaning' takes an s-expr object and a context/environment and computes the +result s-expr. it recursively looks at each node in the s-expr, decides what +action needs to be taken on it, and executes the action. possible actions (aka, +parsed types) are: + + const (atomic values) + lambda + quote (s-expr "one level down") + identifier (a symbol to be looked up in the context) + cond (conditional expression) + +The specific list of "special"/"built-in"/"reserved" identifiers is: + + lambda + quote + cond + else + cons + car + cdr + null? + eq? + atom? + zero? + number? + +Things which an be applied are lambdas and the above built-ins. + +When applying a lambda, need to bind values to local context. This requires +an immutable or copied lookup table. + -- cgit v1.2.3