OSDN Git Service

Updating the first notebook.
authorSimon Forman <sforman@hushmail.com>
Tue, 23 Nov 2021 18:11:46 +0000 (10:11 -0800)
committerSimon Forman <sforman@hushmail.com>
Tue, 23 Nov 2021 18:11:46 +0000 (10:11 -0800)
It's not done, but it's a start. (^_^)

docs/0._This_Implementation_of_Joy_in_Python.ipynb
docs/README.md

index 0a4b784..fcebaa8 100644 (file)
@@ -8,9 +8,7 @@
     "\n",
     "## Joy in Python\n",
     "\n",
-    "This implementation is meant as a tool for exploring the programming model and method of Joy.  Python seems like a great implementation language for Joy for several reasons.\n",
-    "\n",
-    "We can lean on the Python immutable types for our basic semantics and types: ints, floats, strings, and tuples, which enforces functional purity.  We get garbage collection for free.  Compilation via Cython.  Glue language with loads of libraries."
+    "This implementation is meant as a tool for exploring the programming model and method of Joy.  Python seems like a great implementation language for Joy for several reasons.  We can lean on the Python immutable types for our basic semantics and types: ints, floats, strings, and tuples, which enforces functional purity.  We get garbage collection for free.  Compilation via Cython.  Glue language with loads of libraries."
    ]
   },
   {
    "source": [
     "# Stacks (aka list, quote, sequence, etc.)\n",
     "\n",
-    "In Joy, in addition to the types Boolean, integer, float, and string, there is a single sequence type represented by enclosing a sequence of terms in brackets `[...]`.  This sequence type is used to represent both the stack and the expression.  It is a [cons list](https://en.wikipedia.org/wiki/Cons#Lists) made from Python tuples."
+    "In Joy, in addition to the types Boolean, integer, float, and string, there is a single sequence type represented by enclosing a sequence of terms in brackets `[...]`.  This sequence type is used to represent both the stack and the expression.  It is a [cons list](https://en.wikipedia.org/wiki/Cons#Lists) made from Python tuples.\n",
+    "\n",
+    "[Documentation of Stack Module](https://joypy.osdn.io/stack.html)"
    ]
   },
   {
-   "cell_type": "code",
-   "execution_count": 1,
+   "cell_type": "markdown",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "When talking about Joy we use the terms \"stack\", \"quote\", \"sequence\",\n",
-      "\"list\", and others to mean the same thing: a simple linear datatype that\n",
-      "permits certain operations such as iterating and pushing and popping\n",
-      "values from (at least) one end.\n",
-      "\n",
-      "There is no \"Stack\" Python class, instead we use the  `cons list`_, a \n",
-      "venerable two-tuple recursive sequence datastructure, where the\n",
-      "empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the\n",
-      "recursive form of a stack with one or more items on it::\n",
-      "\n",
-      "    stack := () | (item, stack)\n",
-      "\n",
-      "Putting some numbers onto a stack::\n",
-      "\n",
-      "    ()\n",
-      "    (1, ())\n",
-      "    (2, (1, ()))\n",
-      "    (3, (2, (1, ())))\n",
-      "    ...\n",
-      "\n",
-      "Python has very nice \"tuple packing and unpacking\" in its syntax which\n",
-      "means we can directly \"unpack\" the expected arguments to a Joy function.\n",
-      "\n",
-      "For example::\n",
-      "\n",
-      "        def dup((head, tail)):\n",
-      "                return head, (head, tail)\n",
-      "\n",
-      "We replace the argument \"stack\" by the expected structure of the stack,\n",
-      "in this case \"(head, tail)\", and Python takes care of unpacking the\n",
-      "incoming tuple and assigning values to the names.  (Note that Python\n",
-      "syntax doesn't require parentheses around tuples used in expressions\n",
-      "where they would be redundant.)\n",
-      "\n",
-      "Unfortunately, the Sphinx documentation generator, which is used to generate this\n",
-      "web page, doesn't handle tuples in the function parameters.  And in Python 3, this\n",
-      "syntax was removed entirely.  Instead you would have to write::\n",
-      "\n",
-      "        def dup(stack):\n",
-      "                head, tail = stack\n",
-      "                return head, (head, tail)\n",
-      "\n",
-      "\n",
-      "We have two very simple functions, one to build up a stack from a Python\n",
-      "iterable and another to iterate through a stack and yield its items\n",
-      "one-by-one in order.  There are also two functions to generate string representations\n",
-      "of stacks.  They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left.  In both functions *internal stacks* are\n",
-      "printed left-to-right.  These functions are written to support :doc:`../pretty`.\n",
-      "\n",
-      ".. _cons list: https://en.wikipedia.org/wiki/Cons#Lists\n"
-     ]
-    }
-   ],
    "source": [
-    "import inspect\n",
-    "import joy.utils.stack\n",
-    "\n",
-    "\n",
-    "print(inspect.getdoc(joy.utils.stack))"
+    "### The utility functions maintain order.\n",
+    "The 0th item in the list will be on the top of the stack and *vise versa*."
    ]
   },
   {
-   "cell_type": "markdown",
+   "cell_type": "code",
+   "execution_count": 1,
    "metadata": {},
+   "outputs": [],
    "source": [
-    "### The utility functions maintain order.\n",
-    "The 0th item in the list will be on the top of the stack and *vise versa*."
+    "from joy.utils.stack import iter_stack, list_to_stack"
    ]
   },
   {
     }
    ],
    "source": [
-    "joy.utils.stack.list_to_stack([1, 2, 3])"
+    "list_to_stack([1, 2, 3])"
    ]
   },
   {
     }
    ],
    "source": [
-    "list(joy.utils.stack.iter_stack((1, (2, (3, ())))))"
+    "list(iter_stack((1, (2, (3, ())))))"
    ]
   },
   {
    "source": [
     "stack = ()\n",
     "\n",
-    "for n in [1, 2, 3]:\n",
+    "for n in (1, 2, 3):\n",
     "    stack = n, stack\n",
     "\n",
     "print(stack)\n",
-    "print(list(joy.utils.stack.iter_stack(stack)))"
+    "print(list(iter_stack(stack)))"
    ]
   },
   {
     "## An Interpreter\n",
     "The `joy()` function is extrememly simple.  It accepts a stack, an expression, and a dictionary, and it iterates through the expression putting values onto the stack and delegating execution to functions it looks up in the dictionary.\n",
     "\n",
-    "Each function is passed the stack, expression, and dictionary and returns them.  Whatever the function returns becomes the new stack, expression, and dictionary.  (The dictionary is passed to enable e.g. writing words that let you enter new words into the dictionary at runtime, which nothing does yet and may be a bad idea, and the `help` command.)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 5,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "def joy(stack, expression, dictionary, viewer=None):\n",
-      "\t'''Evaluate a Joy expression on a stack.\n",
-      "\n",
-      "\tThis function iterates through a sequence of terms which are either\n",
-      "\tliterals (strings, numbers, sequences of terms) or function symbols.\n",
-      "\tLiterals are put onto the stack and functions are looked up in the\n",
-      "\tdisctionary and executed.\n",
-      "\n",
-      "\tThe viewer is a function that is called with the stack and expression\n",
-      "\ton every iteration, its return value is ignored.\n",
-      "\n",
-      "\t:param stack stack: The stack.\n",
-      "\t:param stack expression: The expression to evaluate.\n",
-      "\t:param dict dictionary: A ``dict`` mapping names to Joy functions.\n",
-      "\t:param function viewer: Optional viewer function.\n",
-      "\t:rtype: (stack, (), dictionary)\n",
-      "\n",
-      "\t'''\n",
-      "\twhile expression:\n",
-      "\n",
-      "\t\tif viewer: viewer(stack, expression)\n",
-      "\n",
-      "\t\tterm, expression = expression\n",
-      "\t\tif isinstance(term, Symbol):\n",
-      "\t\t\tterm = dictionary[term]\n",
-      "\t\t\tstack, expression, dictionary = term(stack, expression, dictionary)\n",
-      "\t\telse:\n",
-      "\t\t\tstack = term, stack\n",
-      "\n",
-      "\tif viewer: viewer(stack, expression)\n",
-      "\treturn stack, expression, dictionary\n",
-      "\n"
-     ]
-    }
-   ],
-   "source": [
-    "import joy.joy\n",
+    "Each function is passed the stack, expression, and dictionary and returns them.  Whatever the function returns becomes the new stack, expression, and dictionary.  (The dictionary is passed to enable e.g. writing words that let you enter new words into the dictionary at runtime, which nothing does yet and may be a bad idea, and the `help` command.)\n",
     "\n",
-    "print(inspect.getsource(joy.joy.joy))"
+    "[Documentation of Joy Module](https://joypy.osdn.io/joy.html)"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "This module exports a single function for converting text to a joy\n",
-      "expression as well as a single Symbol class and a single Exception type.\n",
-      "\n",
-      "The Symbol string class is used by the interpreter to recognize literals\n",
-      "by the fact that they are not Symbol objects.\n",
-      "\n",
-      "A crude grammar::\n",
-      "\n",
-      "    joy = term*\n",
-      "    term = int | float | string | '[' joy ']' | symbol\n",
-      "\n",
-      "A Joy expression is a sequence of zero or more terms.  A term is a\n",
-      "literal value (integer, float, string, or Joy expression) or a function\n",
-      "symbol.  Function symbols are unquoted strings and cannot contain square\n",
-      "brackets.   Terms must be separated by blanks, which can be omitted\n",
-      "around square brackets.\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
-    "import joy.parser\n",
-    "\n",
-    "print(inspect.getdoc(joy.parser))"
+    "from joy.parser import text_to_expression"
    ]
   },
   {
    ]
   },
   {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "def _parse(tokens):\n",
-      "\t'''\n",
-      "\tReturn a stack/list expression of the tokens.\n",
-      "\t'''\n",
-      "\tframe = []\n",
-      "\tstack = []\n",
-      "\tfor tok in tokens:\n",
-      "\t\tif tok == '[':\n",
-      "\t\t\tstack.append(frame)\n",
-      "\t\t\tframe = []\n",
-      "\t\t\tstack[-1].append(frame)\n",
-      "\t\telif tok == ']':\n",
-      "\t\t\ttry:\n",
-      "\t\t\t\tframe = stack.pop()\n",
-      "\t\t\texcept IndexError:\n",
-      "\t\t\t\traise ParseError('Extra closing bracket.')\n",
-      "\t\t\tframe[-1] = list_to_stack(frame[-1])\n",
-      "\t\telse:\n",
-      "\t\t\tframe.append(tok)\n",
-      "\tif stack:\n",
-      "\t\traise ParseError('Unclosed bracket.')\n",
-      "\treturn list_to_stack(frame)\n",
-      "\n"
-     ]
-    }
-   ],
-   "source": [
-    "print(inspect.getsource(joy.parser._parse))"
-   ]
-  },
-  {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "That's pretty much all there is to it."
+    "A simple sequence."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
        "(1, (2, (3, (4, (5, ())))))"
       ]
      },
-     "execution_count": 8,
+     "execution_count": 6,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "joy.parser.text_to_expression('1 2 3 4 5')  # A simple sequence."
+    "text_to_expression('1 2 3 4 5')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Three items, the first is a list with three items"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
        "((1, (2, (3, ()))), (4, (5, ())))"
       ]
      },
-     "execution_count": 9,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "joy.parser.text_to_expression('[1 2 3] 4 5')  # Three items, the first is a list with three items"
+    "text_to_expression('[1 2 3] 4 5')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "A mixed bag."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "(1, (23, (('four', ((-5.0, ()), (cons, ()))), (8888, ()))))"
+       "(1, (23, ((\"four\", ((-5.0, ()), (cons, ()))), (8888, ()))))"
       ]
      },
-     "execution_count": 10,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "joy.parser.text_to_expression('1 23 [\"four\" [-5.0] cons] 8888')  # A mixed bag. cons is\n",
-    "                                                                 # a Symbol, no lookup at\n",
-    "                                                                 # parse-time.  Haiku docs."
+    "text_to_expression('1 23 [\"four\" [-5.0] cons] 8888')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Five empty lists."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
        "((), ((), ((), ((), ((), ())))))"
       ]
      },
-     "execution_count": 11,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "joy.parser.text_to_expression('[][][][][]')  # Five empty lists."
+    "text_to_expression('[][][][][]')"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Five nested lists."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
        "((((((), ()), ()), ()), ()), ())"
       ]
      },
-     "execution_count": 12,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "joy.parser.text_to_expression('[[[[[]]]]]')  # Five nested lists."
+    "text_to_expression('[[[[[]]]]]')"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "!= % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken div divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd ge genrec getitem gt help i id ifte ii infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons tailrec take ternary third times truediv truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •\n"
+      "!= % & * *fraction *fraction0 + ++ - -- / // /floor < << <= <> = > >= >> ? ^ _Tree_add_Ee _Tree_delete_R0 _Tree_delete_clear_stuff _Tree_get_E abs add anamorphism and app1 app2 app3 at average b binary bool branch ccons choice clear cleave cmp codireco concat cond cons dinfrirst dip dipd dipdd disenstacken div divmod down_to_zero drop dup dupd dupdd dupdip dupdipd enstacken eq first first_two flatten floor floordiv fork fourth gcd gcd2 ge genrec getitem gt help i id ifte ii infra inscribe le least_fraction loop lshift lt make_generator map max min mod modulus mul ne neg not nullary of or over pam parse pick pm pop popd popdd popop popopd popopdd pow pred primrec product quoted range range_to_zero rem remainder remove rest reverse roll< roll> rolldown rollup round rrest rshift run second select sharing shunt size sort sqr sqrt stack step step_zero stuncons stununcons sub succ sum swaack swap swoncat swons tailrec take ternary third times truthy tuck unary uncons unique unit unquoted unstack unswons void warranty while words x xor zip •\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 12,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import inspect"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "@inscribe\n",
-      "@FunctionWrapper\n",
-      "def dip(stack, expression, dictionary):\n",
-      "\t'''\n",
-      "\tThe dip combinator expects a quoted program on the stack and below it\n",
-      "\tsome item, it hoists the item into the expression and runs the program\n",
-      "\ton the rest of the stack.\n",
-      "\t::\n",
-      "\n",
-      "\t\t   ... x [Q] dip\n",
-      "\t\t-------------------\n",
-      "\t\t     ... Q x\n",
+      "The dip combinator expects a quoted program on the stack and below it\n",
+      "some item, it hoists the item into the expression and runs the program\n",
+      "on the rest of the stack.\n",
+      "::\n",
       "\n",
-      "\t'''\n",
-      "\t(quote, (x, stack)) = stack\n",
-      "\texpression = (x, expression)\n",
-      "\treturn stack, concat(quote, expression), dictionary\n",
-      "\n"
+      "       ... x [Q] dip\n",
+      "    -------------------\n",
+      "         ... Q x\n"
      ]
     }
    ],
    "source": [
-    "print(inspect.getsource(joy.library.dip))"
+    "print(inspect.getdoc(joy.library.dip))"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Some functions are defined in equations in terms of other functions.  When the interpreter executes a definition function that function just pushes its body expression onto the pending expression (the continuation) and returns control to the interpreter."
+    "The code (I was using ``inspect.getsource()`` here to automatically print the souce but it was not as nice-looking that way due to lack of syntax highlighting and the docstring being too long for the width of the element and wrapping in an ungainly way.  SO now, instead, I'm just including it as a Python cell in the notebook):"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "def dip(stack, expression, dictionary):\n",
+    "    try:\n",
+    "        (quote, (x, stack)) = stack\n",
+    "    except ValueError:\n",
+    "        raise StackUnderflowError('Not enough values on stack.')\n",
+    "    return stack, concat(quote, (x, expression)), dictionary"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Some functions are defined in equations in terms of other functions.  When the interpreter executes a definition function that function just pushes its body expression onto the pending expression (the continuation) and returns control to the interpreter.\n",
+    "\n",
+    "(Note that the embedded ``joy.library.definitions`` is going away in favor of a ``def.txt`` file that would be read in at start-time. See\n",
+    "[Ticket: thun-der#7](https://todo.sr.ht/~sforman/thun-der/7))"
    ]
   },
   {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "? dup truthy\n",
-      "*fraction [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons\n",
-      "*fraction0 concat [[swap] dip * [*] dip] infra\n",
-      "anamorphism [pop []] swap [dip swons] genrec\n",
-      "average [sum 1.0 *] [size] cleave /\n",
-      "binary nullary [popop] dip\n",
-      "cleave fork [popd] dip\n",
-      "codireco cons dip rest cons\n",
-      "dinfrirst dip infra first\n",
-      "unstack ? [uncons ?] loop pop\n",
-      "down_to_zero [0 >] [dup --] while\n",
-      "dupdipd dup dipd\n",
-      "enstacken stack [clear] dip\n",
-      "flatten [] swap [concat] step\n",
-      "fork [i] app2\n",
-      "gcd 1 [tuck modulus dup 0 >] loop pop\n",
-      "ifte [nullary not] dipd branch\n",
-      "ii [dip] dupdip i\n",
-      "least_fraction dup [gcd] infra [div] concat map\n",
-      "make_generator [codireco] ccons\n",
-      "nullary [stack] dinfrirst\n",
-      "of swap at\n",
-      "pam [i] map\n",
-      "tailrec [i] genrec\n",
-      "product 1 swap [*] step\n",
-      "quoted [unit] dip\n",
-      "range [0 <=] [1 - dup] anamorphism\n",
-      "range_to_zero unit [down_to_zero] infra\n",
-      "run [] swap infra\n",
-      "size 0 swap [pop ++] step\n",
-      "sqr dup mul\n",
-      "step_zero 0 roll> step\n",
-      "swoncat swap concat\n",
-      "tailrec [i] genrec\n",
-      "ternary unary [popop] dip\n",
-      "unary nullary popd\n",
-      "unquoted [i] dip\n",
-      "while swap [nullary] cons dup dipd concat loop\n",
+      "? == dup truthy\n",
+      "*fraction == [uncons] dip uncons [swap] dip concat [*] infra [*] dip cons\n",
+      "*fraction0 == concat [[swap] dip * [*] dip] infra\n",
+      "anamorphism == [pop []] swap [dip swons] genrec\n",
+      "average == [sum 1.0 *] [size] cleave /\n",
+      "binary == nullary [popop] dip\n",
+      "cleave == fork [popd] dip\n",
+      "codireco == cons dip rest cons\n",
+      "dinfrirst == dip infra first\n",
+      "unstack == ? [uncons ?] loop pop\n",
+      "down_to_zero == [0 >] [dup --] while\n",
+      "dupdipd == dup dipd\n",
+      "enstacken == stack [clear] dip\n",
+      "flatten == [] swap [concat] step\n",
+      "fork == [i] app2\n",
+      "gcd == 1 [tuck modulus dup 0 >] loop pop\n",
+      "ifte == [nullary not] dipd branch\n",
+      "ii == [dip] dupdip i\n",
+      "least_fraction == dup [gcd] infra [div] concat map\n",
+      "make_generator == [codireco] ccons\n",
+      "nullary == [stack] dinfrirst\n",
+      "of == swap at\n",
+      "pam == [i] map\n",
+      "tailrec == [i] genrec\n",
+      "product == 1 swap [*] step\n",
+      "quoted == [unit] dip\n",
+      "range == [0 <=] [1 - dup] anamorphism\n",
+      "range_to_zero == unit [down_to_zero] infra\n",
+      "run == [] swap infra\n",
+      "size == 0 swap [pop ++] step\n",
+      "sqr == dup mul\n",
+      "step_zero == 0 roll> step\n",
+      "swoncat == swap concat\n",
+      "tailrec == [i] genrec\n",
+      "ternary == unary [popop] dip\n",
+      "unary == nullary popd\n",
+      "unquoted == [i] dip\n",
+      "while == swap [nullary] cons dup dipd concat loop\n",
       "\n"
      ]
     }
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Currently, there's no function to add new definitions to the dictionary from \"within\" Joy code itself.  Adding new definitions remains a meta-interpreter action.  You have to do it yourself, in Python, and wash your hands afterward.\n",
+    "Currently, there's no function to add new definitions to the dictionary from \"within\" Joy code itself.  (Actually there is, it's called ``inscribe``, but don't use it, eh? :) Adding new definitions remains a meta-interpreter action.  You have to do it yourself, in Python, and wash your hands afterward.\n",
     "\n",
     "It would be simple enough to define one, but it would open the door to *name binding* and break the idea that all state is captured in the stack and expression.  There's an implicit *standard dictionary* that defines the actual semantics of the syntactic stack and expression datastructures (which only contain symbols, not the actual functions.  Pickle some and see for yourself.)\n",
     "\n",
     "\n",
     "But my point now is that this great ratio of textual explanation to wind up with code that consists of a few equations and could fit on an index card is highly desirable.  Less code has fewer errors.  The structure of Joy engenders a kind of thinking that seems to be very effective for developing structured processes.\n",
     "\n",
-    "There seems to be an elegance and power to the notation.\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "  "
+    "There seems to be an elegance and power to the notation."
    ]
   }
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 2",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
-   "name": "python2"
+   "name": "python3"
   },
   "language_info": {
    "codemirror_mode": {
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.3"
+   "version": "3.7.10"
   }
  },
  "nbformat": 4,
index 874c753..19f3dcf 100644 (file)
@@ -1,33 +1,26 @@
-# Some Jupyter Notebooks and other material.
+# Thun Documentation Documentation
 
-All of the notebooks are also available as HTML and Markdown files
-(generated using nbconvert) so you can view them without running Jupyter.
+Most of the docs take the form of some [Jupyter](https://jupyter.org/index.html) notebooks.
 
-In order to run the [Jupyter Notebooks](https://jupyter.org/index.html)
-you need Jupyter (obviously) and you should install `Joypy`.  Here's an
-example using `virtualenv` from the project directory:
+The notebooks are converted (using [nbconvert](https://nbconvert.readthedocs.io/en/latest/install.html)) to HTML, Markdown, and ReST files so you can view them without running Jupyter.
 
-    virtualenv --system-site-packages venv
-    source ./venv/bin/activate
-    pip install notebook
-    python ./setup.py install
+## Running the Notebooks with [Jupyter](https://jupyter.org/index.html)
 
-Once that's done you should be able to start Jupyter Notebook server
-with, e.g.:
+In order to run the [Jupyter](https://jupyter.org/index.html) notebooks
+you need [Jupyter](https://jupyter.org/index.html) (obviously):
+
+[Installing the classic Jupyter Notebook interface](https://jupyter.readthedocs.io/en/latest/install/notebook-classic.html)
 
-    python -m notebook --ip=0.0.0.0
+And, of course, you should install `Thun` (see the main project README or the
+[online docs](https://joypy.osdn.io/#quick-start)).
 
-This starts it using the `virtualenv` version of Python so `joy` will be
-available.  Navigate to the `joypy/docs` directory and the notebooks
-should be able to import the `notebook_preamble.py` file.
+Once that's done you should be able to start Jupyter Notebook server
+in the `joypy/docs` directory and run the notebooks.
 
-I find I have to include `--ip=0.0.0.0` to workaround a bug where it
-tries to bind to an IPv6 address, YMMV.
 
-Clean up when you're done:
+## ``notebook_preamble.py``
 
-    deactivate 
-    rm -rf venv
+...something about the `notebook_preamble.py` file.