From 55e30e4de0c2310cd9ef4e4af998594b57f25dd6 Mon Sep 17 00:00:00 2001 From: Jeremy Huiskamp Date: Thu, 11 Jan 2024 23:31:33 +0100 Subject: [PATCH] update guidance around division by zero Ruby doesn't throw an exception when dividing by 0.0, which is the equivalent to dividing by 0 in Lox. Rather, it does the same thing as java (and javascript, and IEEE754) in returning Infinity/-Infinity/NaN. Python seems to be the outlier here. --- note/answers/chapter07_evaluating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/note/answers/chapter07_evaluating.md b/note/answers/chapter07_evaluating.md index d034677e8..6d1b792a1 100644 --- a/note/answers/chapter07_evaluating.md +++ b/note/answers/chapter07_evaluating.md @@ -32,7 +32,7 @@ 3. It returns Infinity, -Infinity, or NaN based on sign of the dividend. Given that Lox is a high level scripting language, I think it would be better to raise a runtime error to let the user know something got weird. That's what - Python and Ruby do. + Python does. On the other hand, given that Lox gives the user no way to catch and handle runtime errors, not throwing one might be more flexible.