Modify working of inscribe command.
Instead of a string it now takes a quote.
This commit is contained in:
parent
688f880b9f
commit
0ce58872ac
|
|
@ -311,6 +311,19 @@ class DefinitionWrapper(object):
|
||||||
class_.add_def(line, dictionary)
|
class_.add_def(line, dictionary)
|
||||||
|
|
||||||
|
|
||||||
|
class Def(DefinitionWrapper):
|
||||||
|
'''
|
||||||
|
Definitions created by inscribe.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, name, body):
|
||||||
|
self.name = name
|
||||||
|
self.body = body
|
||||||
|
self._body = tuple(iter_stack(body))
|
||||||
|
self.__doc__ = expression_to_string(body)
|
||||||
|
self._compiled = None
|
||||||
|
|
||||||
|
|
||||||
def _text_to_defs(text):
|
def _text_to_defs(text):
|
||||||
return (
|
return (
|
||||||
line.strip()
|
line.strip()
|
||||||
|
|
@ -331,16 +344,15 @@ def _text_to_defs(text):
|
||||||
def inscribe_(stack, expression, dictionary):
|
def inscribe_(stack, expression, dictionary):
|
||||||
'''
|
'''
|
||||||
Create a new Joy function definition in the Joy dictionary. A
|
Create a new Joy function definition in the Joy dictionary. A
|
||||||
definition is given as a string with a name followed by a double
|
definition is given as a quote with a name followed by a Joy
|
||||||
equal sign then one or more Joy functions, the body. for example:
|
expression. for example:
|
||||||
|
|
||||||
sqr == dup mul
|
[sqr dup mul] inscribe
|
||||||
|
|
||||||
If you want the definition to persist over restarts, enter it into
|
|
||||||
the definitions.txt resource.
|
|
||||||
'''
|
'''
|
||||||
definition, stack = stack
|
(name, body), stack = stack
|
||||||
DefinitionWrapper.add_def(definition, dictionary, fail_fails=True)
|
d = Def(name, body)
|
||||||
|
dictionary[d.name] = d
|
||||||
return stack, expression, dictionary
|
return stack, expression, dictionary
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue