From d2b70f5865e7cdfce3a9cfbaf5eb42a33bc4ebd8 Mon Sep 17 00:00:00 2001 From: crc Date: Tue, 6 Mar 2018 16:40:19 +0000 Subject: [PATCH] fix example/NumbersWithoutPrefix.forth for single digits (thanks to kiyoshi for noticing this) FossilOrigin-Name: aca9b86d89658976a7939525039b687226dc2f93ff4455a9fa4b1b0263ab85d7 --- example/NumbersWithoutPrefix.forth | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/example/NumbersWithoutPrefix.forth b/example/NumbersWithoutPrefix.forth index b2a5380..085d2f5 100644 --- a/example/NumbersWithoutPrefix.forth +++ b/example/NumbersWithoutPrefix.forth @@ -27,6 +27,22 @@ the handler) and pass it to `s:to-number` and `class:data`. }} ~~~ +For single digits, define each digit as a word. (Prefixes +are not processed for tokens with nothing other than the +prefix character, so this takes care of the issue). + +~~~ +:1 (-n) #1 ; +:2 (-n) #2 ; +:3 (-n) #3 ; +:4 (-n) #4 ; +:5 (-n) #5 ; +:6 (-n) #6 ; +:7 (-n) #7 ; +:8 (-n) #8 ; +:9 (-n) #9 ; +~~~ + Handling negative numbers is a bigger headache though. By convention, RETRO uses - to imply "not" (as in `-eq?`). So to handle the `-` prefix for numbers, it needs to fall back