From fbdd79a8dba56ad8d7425f3a9c3db1dfdd1d8968 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Fri, 9 Apr 2021 17:04:54 -0700 Subject: [PATCH] Integer division only please. --- joy/library.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/joy/library.py b/joy/library.py index 72516a0..c5d7429 100644 --- a/joy/library.py +++ b/joy/library.py @@ -70,8 +70,7 @@ ALIASES = ( ('and', ['&']), ('bool', ['truthy']), ('mul', ['*']), - ('floordiv', ['/floor', '//']), - ('truediv', ['/', 'div']), + ('floordiv', ['/floor', '//', '/', 'div']), ('mod', ['%', 'rem', 'remainder', 'modulus']), ('eq', ['=']), ('ge', ['>=']), @@ -1165,7 +1164,10 @@ def dip(stack, expression, dictionary): ... Q x ''' - (quote, (x, stack)) = stack + try: + (quote, (x, stack)) = stack + except ValueError: + raise StackUnderflowError expression = (x, expression) return stack, concat(quote, expression), dictionary @@ -1425,7 +1427,7 @@ for F in ( BinaryBuiltinWrapper(operator.mul), BinaryBuiltinWrapper(operator.pow), BinaryBuiltinWrapper(operator.sub), - BinaryBuiltinWrapper(operator.truediv), +## BinaryBuiltinWrapper(operator.truediv), UnaryBuiltinWrapper(bool), UnaryBuiltinWrapper(operator.not_),