@inscribe
+@FunctionWrapper
+def inscribe_(stack, expression, dictionary):
+ '''
+ Create a new Joy function definition in the Joy dictionary. A
+ definition is given as a string with a name followed by a double
+ equal sign then one or more Joy functions, the body. for example:
+
+ sqr == dup mul
+
+ If you want the definition to persist over restarts, enter it into
+ the definitions.txt resource.
+ '''
+ definition, stack = stack
+ DefinitionWrapper.add_def(definition, dictionary)
+ return stack, expression, dictionary
+
+
+@inscribe
@SimpleFunctionWrapper
def parse(stack):
'''Parse the string on the stack to a Joy expression.'''
prefix = 'i'
+class TextJoyType(FloatJoyType):
+ accept = basestring
+ prefix = 't'
+
+
class StackJoyType(AnyJoyType):
accept = tuple
S = s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 = map(StackJoyType, _R)
F = f0, f1, f2, f3, f4, f5, f6, f7, f8, f9 = map(FloatJoyType, _R)
I = i0, i1, i2, i3, i4, i5, i6, i7, i8, i9 = map(IntJoyType, _R)
+T = t0, t1, t2, t3, t4, t5, t6, t7, t8, t9 = map(TextJoyType, _R)
def defs():
dupd = __(a2, a1), __(a2, a2, a1)
dupdd = __(a3, a2, a1), __(a3, a3, a2, a1)
first = __((a1, s1),), __(a1,)
+ inscribe = __(t1), __()
over = __(a2, a1), __(a2, a1, a2)
pop = __(a1), __()
popd = __(a2, a1,), __(a1)