From d96f0bbb99acc2f872ff897a467bd3f49ab133c1 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 24 Nov 2021 15:05:55 -0800 Subject: [PATCH] Modify the inscribe decorator to accept a dict. --- joy/library.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/joy/library.py b/joy/library.py index ee67aa6..47d919b 100644 --- a/joy/library.py +++ b/joy/library.py @@ -58,9 +58,9 @@ HELP_TEMPLATE = '''\ _dictionary = {} -def inscribe(function): +def inscribe(function, d=_dictionary): '''A decorator to inscribe functions into the default dictionary.''' - _dictionary[function.name] = function + d[function.name] = function return function @@ -351,8 +351,7 @@ def inscribe_(stack, expression, dictionary): ''' (name, body), stack = stack - d = Def(name, body) - dictionary[d.name] = d + inscribe(Def(name, body), dictionary) return stack, expression, dictionary