commit 96ff55e3fe26ec65ec1d0e08e304b6068791c1a5
parent f79e0d0b552a9e7c3e4b6b9efa1073cf8f22fd91
Author: Andres Navarro <canavarro82@gmail.com>
Date: Wed, 27 Apr 2011 19:02:25 -0300
Corrected README and some comments to acknowledge support for rationals. Added bigint support for integer->char (just throws an error, out-of-range).
Diffstat:
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/README b/README
@@ -8,7 +8,7 @@ README for klisp 0.1
that probably won't happen for some time. It is written in C99 under
the MIT license. It draws heavily from the Lua interpreter source
code & file structure. It uses the IMath library for arbitrary sized
- integers and (soon) rationals.
+ integers and rationals.
* What is the Kernel Programming Language?
----------------------------------------
diff --git a/src/kgchars.c b/src/kgchars.c
@@ -49,15 +49,17 @@ void kchar_to_integer(klisp_State *K, TValue *xparams, TValue ptree,
kapply_cc(K, i2tv((int32_t) chvalue(ch)));
}
-/* TEMP: this should arbitrary integers (and throw an error if out of
- range */
void kinteger_to_char(klisp_State *K, TValue *xparams, TValue ptree,
TValue denv)
{
UNUSED(xparams);
UNUSED(denv);
- bind_1tp(K, "integer->char", ptree, "finite integer", ttisfixint, itv);
+ bind_1tp(K, "integer->char", ptree, "integer", ttisinteger, itv);
+ if (ttisbigint(itv)) {
+ klispE_throw(K, "integer->char: integer out of ASCII range [0 - 127]");
+ return;
+ }
int32_t i = ivalue(itv);
/* for now only allow ASCII */
diff --git a/src/kground.c b/src/kground.c
@@ -651,7 +651,7 @@ void kinit_ground_env(klisp_State *K)
**
*/
- /* Only integers and exact infinities for now */
+ /* Only integers, rationals and exact infinities for now */
/*
** 12.5 Number features
diff --git a/src/ktoken.c b/src/ktoken.c
@@ -391,7 +391,7 @@ int32_t ktok_read_until_delimiter(klisp_State *K)
/*
** Numbers
-** TEMP: for now, only integers, ignore exactness
+** TEMP: for now, only integers & rationals
** The digits are in buf, that must be freed after use,
** len should be at least one
*/